Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <string>
- #define forn(I,B) for (int I=1;I<=(B);I++)
- #define rep(I,B) for (int I=0;I<(B);I++)
- using namespace std;
- string vals[555],buf,s;
- int ptr,n;
- bool cmp(string a,string b){
- int x=a.length(),y=b.length();
- if (x!=y) return x<y;
- rep(i,x) if (a[i]!=b[i]) return a[i]<b[i];
- return 0;
- }
- int main(){
- cin>>n;
- forn(i,n){
- cin>>s;
- int l=s.length();
- rep(j,l)
- if (s[j]>='0' && s[j]<='9'){
- buf="";
- while (j<l && s[j]>='0' && s[j]<='9') buf+=s[j++];
- while (buf[0]=='0' && buf.length()>1) buf.erase(0,1);
- vals[++ptr]=buf;
- }
- }
- sort(vals+1,vals+ptr+1,cmp);
- forn(i,ptr) cout<<vals[i]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment