当前位置:网站首页>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;
}
边栏推荐
- 表单文本框的使用(一) 选择文本
- 556. The next larger element III
- Leetcode(4)——尋找兩個正序數組的中比特數
- Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
- Convert string to decimal integer
- 7-15 calculation of PI
- 愉悦资本新双币基金近40亿元完成首次关账
- 适用于XP的DDK
猜你喜欢
Creation of data table of Doris' learning notes
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
分布式事务(Seata) 四大模式详解
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
Mysql多表查询 #子查询
retrofit
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
Exercise 8-8 moving letters
Exercise 6-6 use a function to output an integer in reverse order
Understanding of closures
随机推荐
MySQL multi table query subquery
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?
Convert string to decimal integer
GRPC的四种数据流以及案例
论文分享:Generating Playful Palettes from Images
6-9 statistics of single digits (15 points)
Statistical capital consonants
Get permissions dynamically
Common commands for getting started with mongodb database
7-16 find the set of integers that meet the given conditions
SSH access control, blocking the IP when logging in repeatedly to prevent brute force cracking
Although not necessarily the best, it must be the hardest!
适用于XP的DDK
Exercise 10-8 recursive implementation of sequential output of integers
Luogu p5536 [xr-3] core city solution
ConstraintLayout 的使用
提高效率 Or 增加成本,开发人员应如何理解结对编程?
J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东