当前位置:网站首页>Address book sorting
Address book sorting
2022-07-03 14:33:00 【Study hard 867】
Input n A friend's information , Including name, 、 Birthday 、 Phone number , This question requires the preparation of procedures , Output the address book in order of age . The title ensures that everyone's birthday is different .
Input format :
Enter the first line to give a positive integer n(<10). And then n That's ok , Each line follows “ full name Birthday Phone number ” Give a friend's information in the format of , among “ full name ” It's no longer than 10 A string of English letters ,“ Birthday ” yes yyyymmdd Format date ,“ Phone number ” No more than 17 Digit numbers and +、- Composed string .
Output format :
Output your friends' information according to their age , The format is the same as that of output .
sample input :
3
zhang 19850403 13912345678
wang 19821020 +86-0571-88018448
qian 19840619 13609876543
sample output :
wang 19821020 +86-0571-88018448
qian 19840619 13609876543
zhang 19850403 13912345678Code :
#include <stdio.h>
#include <stdlib.h>
struct friend
{
char name[10];
int brithday;
char phone[17];
};
int main()
{
int n,i,j;
int min;
struct friend a[11];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("\n");
scanf("%s %d %s",&a[i].name,&a[i].brithday,&a[i].phone);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-1-i;j++)
{
if(a[j].brithday>a[j+1].brithday)
{
a[10]=a[j];
a[j]=a[j+1];
a[j+1]=a[10];
}
}
}
for(i=0;i<n;i++)
{
printf("%s %d %s\n",a[i].name,a[i].brithday,a[i].phone);
}
return 0;
}
边栏推荐
- 一文了解微分段应用场景与实现机制
- 556. The next larger element III
- adc128s022 ADC verilog设计实现
- Adc128s022 ADC Verilog design and Implementation
- Recent learning summary
- Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
- Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
- 7-19 check denomination (solve binary linear equation)
- 7-24 reduction of the simplest fraction (rolling Division)
- tonybot 人形机器人 红外遥控玩法 0630
猜你喜欢

How to query the baby category of tmall on Taobao

Why is this error reported when modifying records in the database
![Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution](/img/89/da1a3a38e02671628f385de0f30369.png)
Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution

Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them

愉悦资本新双币基金近40亿元完成首次关账

Puzzle (016.3) is inextricably linked

Exercise 10-1 calculate the sum of 1 to n using recursive functions

tonybot 人形机器人 首次开机 0630

Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in

protobuf与grpc
随机推荐
Sword finger offer 28 Symmetric binary tree
洛谷P3065 [USACO12DEC]First! G 题解
Solr series of full-text search engines - basic principles of full-text search
npm install卡住与node-npy的各种奇怪报错
7-2 and then what time (15 minutes)
Luogu p4047 [jsoi2010] tribal division solution
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
GRPC的四种数据流以及案例
tonybot 人形机器人 定距移动 代码编写玩法
Table of mathematical constants by q779
Exercise 10-6 recursively find Fabonacci sequence
7-20 print 99 formula table (format output)
China PETG market forecast and Strategic Research Report (2022 Edition)
tonybot 人形机器人 红外遥控玩法 0630
fpga阻塞赋值和非阻塞赋值
Although not necessarily the best, it must be the hardest!
Tonybot Humanoïde Robot Infrared Remote play 0630
String substitution
Niuke: crossing the river
论文分享:Generating Playful Palettes from Images