Description
As we all know, there are a lot of water kings in the forums now, so many of them have to use high-precision numbers to keep them.
Now Acmforum decided to hold a water king tournament,
The rules of the game are to keep these water kings until April 28, 2007 23:59 59 seconds The total number of stickers sent from the moment to the beginning is sorted from large to small.
Every water king of course wants to get as far as possible, so they try their best to make irrigation by all means.
Finally, the exciting moment has come, April 29, 2007 0:0 0 seconds, you as the referee got each king of the number of posts,
Now, your task is to simply sort the water kings from large to small by the number of posts.
Input
The first line of input is an integer n of 1 to 1000, indicating that a total of N water Kings participated in the tournament. The following gives a description of each water king, and a description of the water King occupies one line,
Preceded by a string consisting only of letters and numbers that are not more than 20 in length, representing the water King's ID,
followed by an integer (non-negative), representing the number of posts for this water king, note that this integer is less than 2,000,000,000.
Output
Output according to the number of posts from small to large row of the water King's ID and the number of posts of the water King, ID and the number of posts separated by a space.
Cannot have any extra characters. If several IDs have the same number of posts, they are arranged in the order in which the IDs are entered.
Sample Input
6Lowai 1986Zhouyuan 2987Maolaoda 2345BuTaoCaiGuai 2548ArthurKing 2003Hyyylr 3185
Sample Output
Lowai 1986ArthurKing 2003Maolaoda 2345BuTaoCaiGuai 2548Zhouyuan 2987Hyyylr 3185
#include <stdio.h>structwaterpince{Charname[ -]; Longamounts;};intMain () {structWaterpince test[1005]; structwaterpince Temp; intN, I,j; inta[2005]; while(SCANF ("%d", &n)! =EOF) { for(i =0; I < n; i++) scanf ("%s%ld", &Test[i].name,&test[i].amounts); for(i =0; I < n-1; i++) { for(j =0; J < N-1I J + +) { if(Test[j].amounts>test[j +1].amounts) {Temp=Test[j]; TEST[J]= Test[j +1]; Test[j+1] =Temp; } } } for(i =0; I < n; i++) printf ("%s%ld\n", Test[i].name, test[i].amounts); } return 0;}
C: You will be the referee (sort)