当前位置:网站首页>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;
}
边栏推荐
- etcd集群权限管理和账号密码使用
- protobuf与grpc
- Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
- 提高效率 Or 增加成本,开发人员应如何理解结对编程?
- Paper sharing: generating playful palettes from images
- Exercise 8-8 moving letters
- 表单文本框的使用(一) 选择文本
- Get permissions dynamically
- Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
- Find the sum of the elements of each row of the matrix
猜你喜欢

Exercise 8-8 moving letters

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

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

剑指 Offer 28. 对称的二叉树

7-11 calculation of residential water charges by sections

天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪

ConstraintLayout 的使用

Showmebug entered Tencent conference, opening the era of professional technical interview

Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them

修改数据库中的记录为什么报这个错
随机推荐
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
MongoDB索引
7-16 find the set of integers that meet the given conditions
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
Understanding of closures
DDK for XP
556. 下一个更大元素 III : 简单构造模拟题
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
洛谷P3065 [USACO12DEC]First! G 题解
7-24 reduction of the simplest fraction (rolling Division)
Exercise 8-8 moving letters
retrofit
GRPC的四种数据流以及案例
JVM garbage collector
Adc128s022 ADC Verilog design and Implementation
Sendmail无法发送邮件及发送过慢解决
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
Pyqt interface production (login + jump page)
分布式事务(Seata) 四大模式详解
ShowMeBug入驻腾讯会议,开启专业级技术面试时代