当前位置:网站首页>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;
}
边栏推荐
- Exercise 10-2 recursive factorial sum
- 7-19 check denomination (solve binary linear equation)
- Adc128s022 ADC Verilog design and Implementation
- MySQL multi table query subquery
- Tonybot humanoid robot starts for the first time 0630
- String sort
- PCB中常用快捷键
- adc128s022 ADC verilog设计实现
- Etcd cluster permission management and account password usage
- Detailed explanation of four modes of distributed transaction (Seata)
猜你喜欢
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
MySQL multi table query subquery
US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars
556. The next larger element III
Why is this error reported when modifying records in the database
How to query the baby category of tmall on Taobao
pyQt界面制作(登录+跳转页面)
论文分享:Generating Playful Palettes from Images
Protobuf and grpc
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
随机推荐
剑指 Offer 28. 对称的二叉树
J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
使用并行可微模拟加速策略学习
适用于XP的DDK
Exercise 6-6 use a function to output an integer in reverse order
Puzzle (016.4) domino effect
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
【北大青鸟昌平校区】互联网行业中,哪些岗位越老越吃香?
Get permissions dynamically
x86汇编语言-从实模式到保护模式 笔记
tonybot 人形机器人 查看端口并对应端口 0701
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
C language,%d% Difference between 2D%2d%02d
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
String reverse order
Common shortcut keys in PCB
Find the sum of the elements of each row of the matrix
Table of mathematical constants by q779
tonybot 人形機器人 紅外遙控玩法 0630