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)