Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cstdio>
- #include <vector>
- #include <string>
- #include <iostream>
- using namespace std;
- int N;
- string V[ 100001 ];
- int brojac;
- int toint ( char A ) {
- if ( A == '0' ) return 0;
- if ( A == '1' ) return 1;
- if ( A == '2' ) return 2;
- if ( A == '3' ) return 3;
- if ( A == '4' ) return 4;
- if ( A == '5' ) return 5;
- if ( A == '6' ) return 6;
- if ( A == '7' ) return 7;
- if ( A == '8' ) return 8;
- if ( A == '9' ) return 9;
- }
- bool cmp ( string A, string B ) {
- if ( A.size() != B.size() ) {
- return A.size() < B.size();
- }
- for ( int i = 0 ; i < A.size() ; ++i ) {
- if ( A[ i ] != B[ i ] ) {
- return toint ( A[ i ] ) < toint ( B[ i ] );
- }
- }
- }
- int main() {
- scanf ( "%d", &N );
- for ( int i = 0 ; i < N ; ++i ) {
- char arr[ 101 ];
- scanf ( "%s", arr );
- for ( int j = 0 ; j < strlen ( arr ) ; ++j ) {
- if ( isdigit ( arr[ j ] ) ) {
- V[ brojac ] += arr[ j ];
- }
- else {
- ++brojac;
- }
- }
- ++brojac;
- }
- sort ( V, V + brojac, cmp );
- for ( int i = 0 ; i < brojac ; ++i ) {
- if ( V[ i ] != "" ) {
- for ( int j = 0 ; j < V[ i ].size() ; ++j ) {
- if ( V[ i ].substr ( 0, 1 ) == "0" ) {
- V[ i ].erase ( 0, 1 );
- }
- else {
- goto here;
- }
- }
- here: ;
- cout << V[ i ] << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement