sloving order
来源:互联网 发布:qq空间模拟登录 php 编辑:程序博客网 时间:2024/06/05 20:30
B - Solving Order
Welcome to HDU to take part in the first CCPC girls' competition!
As a pretty special competition, many volunteers are preparing for it with high enthusiasm.
One thing they need to do is blowing the balloons.
Before sitting down and starting the competition, you have just passed by the room where the boys are blowing the balloons. And you have found that the number of balloons of different colors are strictly different.
After thinking about the volunteer boys' sincere facial expressions, you noticed that, the problem with more balloon numbers are sure to be easier to solve.
Now, you have recalled how many balloons are there of each color.
Please output the solving order you need to choose in order to finish the problems from easy to hard.
You should print the colors to represent the problems.
Input
The first line is an integer T
which indicates the case number.
And as for each case, the first line is an integer n, which is the number of problems.
Then there are n lines followed, with a string and an integer in each line, in thei-th line, the string means the color of ballon for thei-th problem, and the integer means the ballon numbers.
It is guaranteed that:
T is about 100.
1≤n≤10.
1≤ string length ≤10.
1≤ bolloon numbers ≤83
.(there are 83 teams :p)
For any two problems, their corresponding colors are different.
For any two kinds of balloons, their numbers are different.
Output
For each case, you need to output a single line.
There should be n
strings in the line representing the solving order you choose.
Please make sure that there is only a blank between every two strings, and there is no extra blank.
Sample Input
3
3
red 1
green 2
yellow 3
1
blue 83
2
red 2
white 1
Sample Output
yellow green red
blue
red white
#include <stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;
struct zhege
{
char color[11];
int num;
};
int cmp(struct zhege q,struct zhege w)
{
return q.num>w.num;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
struct zhege e[101];
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",e[i].color,&e[i].num);
}
sort(e,e+n,cmp);
for(i=0;i<n;i++)
{
if(i==0)
{
printf("%s",e[i].color);
}
else printf(" %s",e[i].color);
}
printf("\n");
}
return 0;
}
注意:c++提交
- sloving order
- EU4-33: Sloving an employee problem
- order
- ORDER
- Order
- FS5-Order
- Order Overfill
- Purchase Order
- Sales Order
- Byte order
- Byte order
- order by
- Order Array
- ORDER BY
- Order By
- order by
- Byte Order
- Checking order
- codeforces 867 C Ordering Pizza
- dubbo架构
- sort
- 虚拟机网络设置
- 【树状数组】【单点修改区间求和】【区间修改单点查询】【单点修改区间最大值查询】
- sloving order
- Where is the Marble
- [数学理论]Cross-Validation(交叉验证)介绍
- Spring boot引入引入fastjson
- open函数
- Building designing
- 使用Struts2基本开发步骤
- 高频交易软硬件是怎么架构的
- 欢迎使用CSDN-markdown编辑器