Hiho No. 214 Week sorting Photo Files (sort)

Source: Internet
Author: User

1. Custom sort, two strings extract all characters and full numbers of sub-segments, if the whole character of the sub-segments are equal, the resulting number size is compared.

1#include <Set>2#include <map>3#include <queue>4#include <deque>5#include <stack>6#include <cmath>7#include <cstdio>8#include <vector>9#include <string>Ten#include <cstring> One#include <fstream> A#include <iostream> -#include <algorithm> - using namespacestd; the  - #defineEPS 1e-8 - #definePI ACOs (-1.0) - #defineINF 0x3f3f3f3f + #defineFast_io Ios::sync_with_stdio (False) - Const intn=123; + stringS[n]; A  at BOOLcmpstringS1,stringS2) { -     intn1=s1.size (); -     intN2=s2.size (); -     strings11="", s22=""; -     intnum1=0, num2=0; -      for(intI=0; i<n1;i++){ in         if(s1[i]>='0'&&s1[i]<='9'){ -S11=S1.SUBSTR (0, i); to              Break; +         } -     } the      for(intI=0; i<n1;i++){ *         if(s1[i]>='0'&&s1[i]<='9'){ $num1=Ten*num1+ (s1[i]-'0');Panax Notoginseng         } -     } the      for(intI=0; i<n2;i++){ +         if(s2[i]>='0'&&s2[i]<='9'){ AS22=S2.SUBSTR (0, i); the              Break; +         } -     } $      for(intI=0; i<n2;i++){ $         if(s2[i]>='0'&&s2[i]<='9'){ -Num2=Ten*num2+ (s2[i]-'0'); -         } the     } -     if(s11==S22) {Wuyi         returnnum1<num2; the     } -     returns11<S22; Wu } -  About intMain () { $     intN; -Cin>>N; -      for(intI=0; i<n;i++) cin>>S[i]; -Sort (s,s+n,cmp); A      for(intI=0; i<n;i++){ +         if(i!=n-1) cout<<s[i]<<Endl; the         Elsecout<<S[i]; -     } $     return 0; the}
View Code

Hiho No. 214 Week sorting Photo Files (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.