HDU 5427 A Problem of sorting

Source: Internet
Author: User

Topic Connection

http://acm.hdu.edu.cn/showproblem.php?pid=5427

A Problem of Sortingdescription

There is many people ' s name and birth in a list. Your task is-to-print the name from young-to-old. (There is no pair of both have the the same age.)

Input

First line contains a single integer $T \leq 100$ which denotes the number of test cases.

For each test case, there was an positive integer $n \ (1 \leq n \leq) $ which denotes the number of People,and next $n $ Lines,each Line have a name and a birth ' s year (1900-2015) separated by one space.

The length of name was positive and not larger than 100.Notice name was only contain letter (s), digit (s) and space (s).

Output

For each case, output $n $ lines.

Sample Input

2
1
Fancycoder 1996
2
Fancycoder 1996
xyz111 1997

Sample Output

Fancycoder
xyz111
Fancycoder

String simple question:

#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < cstdio> #include <vector> #include <queue> #include <set>using std::set;using std::sort;using std: :p air;using std::swap;using std::queue;using std::multiset; #define PB (E) push_back (e) #define SZ (c) (int) (c). Size () # Define MP (A, b) Make_pair (A, B) #define ALL (c) (c). Begin (), (c). End () #define ITER (c) Decltype ((c). Begin ()) #define CLS (arr , Val) memset (arr, Val, sizeof (arr)) #define Cpresent (C, E) (Find (All (c), (e))! = (c). End ()) #define REP (i, n) for (int i = 0 ; I < (int) n;  i++) #define TR (c, I) for (ITER (c) i = (c). Begin (); I! = (c). end (); ++i) const int N = 110;const int INF = 0x3f3f3f3f;typedef unsigned long long ull;struct node {int Age;char name[n];inline bool operator< (const Node &x) const {return age &G T X.age;}} A[n];int Main () {#ifdef localfreopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w+", stdout); #endifint T, N;char buf[200] , digit[5];scanf ("%d", &t);while (t--) {scanf ("%d", &n), GetChar (), Rep (i, N) {gets (BUF); int V, j = 0, Len = strlen (BUF); for (; J < 4; j + +) Digi T[J] = buf[len-4 + j];d igit[j] = ' + '; v = atoi (digit); buf[len-5] = ' + '; A[i].age = V, strcpy (A[i].name, buf);} Sort (A, a + N); Rep (i, N) printf ("%s\n", A[i].name);} return 0;}

Hdu 5427 A problem of sorting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.