当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

Exercise 10-3 recursive implementation of exponential functions

必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿

Paper sharing: generating playful palettes from images

Puzzle (016.4) domino effect
![[clean up the extraordinary image of Disk C]](/img/0d/331115bc5d82d6337ae975a08494b2.jpg)
[clean up the extraordinary image of Disk C]

编程语言:类型系统的本质

表单文本框的使用(一) 选择文本

Adc128s022 ADC Verilog design and Implementation

修改数据库中的记录为什么报这个错

Niuke: crossing the river
随机推荐
洛谷P5536 【XR-3】核心城市 题解
Luogu p3065 [usaco12dec]first! G problem solution
Tonybot humanoid robot checks the port and corresponds to port 0701
Sendmail can't send mail and it's too slow to send. Solve it
Puzzle (016.4) domino effect
Leetcode (4) -- find the median of two positively ordered arrays
添加Zabbix计算类型项目Calculated items
全文检索引擎Solr系列—–全文检索基本原理
Jiuyi cloud black free encryption free version source code
Sendmail无法发送邮件及发送过慢解决
【北大青鸟昌平校区】互联网行业中,哪些岗位越老越吃香?
Four data flows and cases of grpc
Understand the application scenario and implementation mechanism of differential segment
LNMP环境mail函数不能发送邮件解决
7-24 reduction of the simplest fraction (rolling Division)
数学常数表 by q779
How to query the baby category of tmall on Taobao
String substitution
[clean up the extraordinary image of Disk C]
Add ZABBIX calculation type itemcalculated items