当前位置:网站首页>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;
}
边栏推荐
- Selective sorting
- tonybot 人形机器人 红外遥控玩法 0630
- 剑指 Offer 28. 对称的二叉树
- MySQL multi table query subquery
- Convert string to decimal integer
- 7-17 crawling worms (break exercise)
- 必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
- 天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
- tonybot 人形机器人 查看端口并对应端口 0701
- [qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
猜你喜欢
![Luogu p4047 [jsoi2010] tribal division solution](/img/7f/3fab3e94abef3da1f5652db35361df.png)
Luogu p4047 [jsoi2010] tribal division solution

pyQt界面制作(登录+跳转页面)

Jiuyi cloud black free encryption free version source code

Understand the application scenario and implementation mechanism of differential segment

Exercise 10-3 recursive implementation of exponential functions

x86汇编语言-从实模式到保护模式 笔记

Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
![[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?](/img/f6/fe61c84f289f0e74a45946dac687a6.jpg)
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?

tonybot 人形机器人 红外遥控玩法 0630

Why is this error reported when modifying records in the database
随机推荐
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
数学常数表 by q779
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
Use of constraintlayout
6-9 statistics of single digits (15 points)
SSH访问控制,多次失败登录即封掉IP,防止暴力破解
String reverse order
Sendmail can't send mail and it's too slow to send. Solve it
Programming language: the essence of type system
retrofit
Too many files with unapproved license
Recent learning summary
剑指 Offer 28. 对称的二叉树
Selective sorting
2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
[clean up the extraordinary image of Disk C]
Sendmail无法发送邮件及发送过慢解决
Puzzle (016.4) domino effect
适用于XP的DDK
How to query the baby category of tmall on Taobao