当前位置:网站首页>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 13912345678
Code :
#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;
}
边栏推荐
- 7-11 calculation of residential water charges by sections
- Creation of data table of Doris' learning notes
- LNMP环境mail函数不能发送邮件解决
- Exercise 10-1 calculate the sum of 1 to n using recursive functions
- Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
- ConstraintLayout 的使用
- Four data flows and cases of grpc
- Luogu p3065 [usaco12dec]first! G problem solution
- Learn to punch in today
- 必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
猜你喜欢
NPM install is stuck with various strange errors of node NPY
Exercise 10-6 recursively find Fabonacci sequence
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
愉悦资本新双币基金近40亿元完成首次关账
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
牛客网:过河卒
Tonybot Humanoïde Robot Infrared Remote play 0630
Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
Creation of data table of Doris' learning notes
随机推荐
Creation of data table of Doris' learning notes
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
7-22 tortoise and rabbit race (result oriented)
Code writing and playing method of tonybot humanoid robot at fixed distance
String substitution
Protobuf and grpc
ConstraintLayout 的使用
Tonybot humanoid robot infrared remote control play 0630
6-9 statistics of single digits (15 points)
Convert string to decimal integer
常见问题之PHP——ldap_add(): Add: Undefined attribute type in
Sendmail无法发送邮件及发送过慢解决
7-20 print 99 formula table (format output)
Paper sharing: generating playful palettes from images
retrofit
7-28 monkeys choose King (Joseph problem)
Doris学习笔记之数据表的创建
puzzle(016.4)多米诺效应
2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
Niuke: crossing the river