C language · ID sort

Source: Internet
Author: User

Algorithm improves identity card sort time limit: 1.0s memory limit: 256.0MBProblem description the Security Bureau searched for a batch of (n) ID numbers and wanted to sort them from large to small by date of birth, and if they had the same date, they were sorted by ID number size. The ID number is 18 digits and the date of birth is 7th through 14th input format the first line an integer n, indicating that there are N ID numbers
The remaining n lines, one ID number per line. The output format is based on the date of birth from the largest to the small sort of social security number, one sample per line input 5
466272307503271156
215856472207097978
234804580401078365
404475727700034980
710351408803093165 Sample Output 404475727700034980
234804580401078365
215856472207097978
710351408803093165
466272307503271156 data size and conventions n<=100000
1#include <iostream>2#include <algorithm>3#include <vector>4 using namespacestd;5 intcmpstringAstringb) {//Custom Sort Functions6     stringBira = A.substr (6,8); 7     stringBIRB = B.substr (6,8); 8     if(Bira! =BIRB)9         returnBira >BIRB;Ten     Else   One         returnA >b; A     return 0;  - }   - intMain () { the     intN;  -scanf"%d",&N);  -vector<string> V (n);//defines a container of type string: V, container size n -      for(intI=0; i<n; i++) +Cin>>V[i]; -Sort (V.begin (), V.end (), CMP);//call your own defined sort function +      for(intI=0; i<n; i++)   Acout<<v[i]<<Endl; at     return 0;  -}

C language/ID card sort

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.