Thứ Ba, 3 tháng 5, 2022

NUMCON C++

#include <bits/stdc++.h>
#define MAX 100000
using namespace std;
string a[MAX],kq,da;
int n;
bool cmp (string x, string y)
{
    if(x!=y)
        return x+y<y+x;
}
void doc(){
 
    while (true){
        n++;
        getline(cin,a[n]);
        if (a[n] == ""){
            n--;
            break;
        }
    }
}
 
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
  //  freopen("NUMCON.inp","r",stdin);
    //freopen("NUMCON.out","w",stdout);
    n=0;
    string s;
  //  getline(cin,s);
    while(cin>>s)
    {        
        n++;
        a[n]=s; 
  //  getline(cin,kq);
    }
    sort(a+1,a+n+1,cmp);
    for(int i=n; i>=1; i--)
        cout<<a[i];
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.