当前位置:网站首页>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;
}
边栏推荐
- Luogu p3065 [usaco12dec]first! G problem solution
- Exercise 8-8 moving letters
- Eight sorts
- 一文了解微分段应用场景与实现机制
- Four data flows and cases of grpc
- 7-14 sum integer segments (C language)
- ZABBIX saves the page blank after adding calculated items
- puzzle(016.3)千丝万缕
- Tonybot humanoid robot starts for the first time 0630
- Strategy, tactics (and OKR)
猜你喜欢

天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库

puzzle(016.3)千丝万缕

泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东

Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块

Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion

一文了解微分段应用场景与实现机制

Pyqt interface production (login + jump page)

Leetcode(4)——尋找兩個正序數組的中比特數

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

Puzzle (016.3) is inextricably linked
随机推荐
String reverse order
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
Tonybot humanoid robot infrared remote control play 0630
7-18 finding the single root of polynomial by dichotomy
Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution
pyQt界面制作(登录+跳转页面)
JVM garbage collector
Doris学习笔记之数据表的创建
String sort
7-28 monkeys choose King (Joseph problem)
Common commands for getting started with mongodb database
SSH access control, blocking the IP when logging in repeatedly to prevent brute force cracking
Add ZABBIX calculation type itemcalculated items
Leetcode(4)——尋找兩個正序數組的中比特數
7-14 sum integer segments (C language)
2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
常见问题之PHP——ldap_add(): Add: Undefined attribute type in
表单文本框的使用(一) 选择文本
ZABBIX saves the page blank after adding calculated items