当前位置:网站首页>Problem B: small challenge
Problem B: small challenge
2022-04-23 03:22:00 【Tang Encheng_ hhhc】
Problem B: Small challenge
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 2544 Solved: 835
Description
Xiaodu's first round victory over human expert Wang Feng , Later, we will challenge human beings in succession . For human dignity , The hall of fame is ranked according to its ability value according to its needs , To meet small challenges .
Input
Multiple sets of test data , Enter an integer for each group T, Represents the number of groups , Enter an integer for each group n (n <= 30), Indicates the number of people in the hall of fame , And then there was n That's ok , Enter the names and Pinyin of the people in the hall of fame on each line ( No more than 10 Letters ) And an integer , This integer represents the ability value of the players in the hall of fame .
Output
For each group of test data , Output one line , According to the ability value from high to low , Export name
Sample Input
1
3
Alice 12
Bob 11
Cate 15
Sample Output
Cate
Alice
Bob
#include <stdio.h>
#include <string>
typedef struct node{
char name[20];
int val;
}node;
int main()
{
int T;
scanf("%d",&T);
while (T--)
{
int n;
scanf("%d",&n);
int i;
node p[33];
for (i = 0;i < n;i++ )
{
scanf("%s%d",p[i].name,&(p[i].val));
//printf("%s %d\n",p[i].name,p[i].val);
//getchar();
}
for (i = 0;i < n-1;i++)
{
for (int j=0;j < n-1-i;j++)
{
if (p[j].val < p[j+1].val)
{
node t = p[j];
p[j] = p[j+1];
p[j+1] = t;
}
}
}
for (i = 0;i < n;i++)
{
printf("%s\n",p[i].name);
}
}
return 0;
}
There is a doubt. , That's why it's defined as
char* name;
scanf("%s",p.name); It can't be used
It's defined as
char[20] name;
scanf("%s",p.name);
You can use it ?
We found the reason , Refer to my article
https://blog.csdn.net/xiaojin_hhhc/article/details/122409210
版权声明
本文为[Tang Encheng_ hhhc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621319894.html
边栏推荐
- socket编程 send()与 recv()函数详解
- 一套组合拳,打造一款 IDEA 护眼方案
- Eight elder brothers chronicle [4]
- Super easy to use asynchronous export function of Excel
- 全新的ORM框架——BeetlSQL介绍
- How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
- Fiddler use
- 关于idea调试模式下启动特别慢的优化
- yes. Net future
- Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
猜你喜欢
二进制文件版本控制工具选择难?看完这篇你会找到答案
New ORM framework -- Introduction to beetlsql
Blazor University (12) - component lifecycle
[untitled]
2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
MySQL索引详解【B+Tree索引、哈希索引、全文索引、覆盖索引】
一文了解全面静态代码分析
超好用的Excel异步导出功能
为什么BI对企业这么重要?
Huawei mobile ADB devices connection device is empty
随机推荐
Mysql database, inconsistent index character set, slow SQL query, interface timeout
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
批量下載文件----壓縮後再下載
一套组合拳,打造一款 IDEA 护眼方案
POI create and export Excel based on data
[MySQL] left function | right function
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
超好用的【通用Excel导入功能】
A set of combination boxing to create an idea eye protection scheme
LoadRunner - performance testing tool
QT dynamic translation of Chinese and English languages
Scenario Title: how does system a use the page of system B
Optimization of especially slow startup in idea debugging mode
Super easy to use asynchronous export function of Excel
Find the number of leaf nodes of binary tree
. net webapi access authorization mechanism and process design (header token + redis)
MySql关键字GROUP_CONCAT,组合连接查询
Five tips for cross-border e-commerce in 2022
OLED multi-level menu record
QT uses drag and drop picture to control and mouse to move picture