Thứ Bảy, 2 tháng 4, 2022

LOCSO c++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,k;
string s;

string maxx(string a,string b)
{
    while(a[0]=='0') a.replace(0,1,"");
    while(b[0]=='0') b.replace(0,1,"");
    if(a=="") return b;
    if(b=="") return a;
    if(a.length()>b.length()) return a;
    if(a.length()<b.length()) return b;
    if(a>b) return a;
    if(a<b) return b;
    return a;
}

void giai()
{
    string res="",t="";
    for(int i=0;i<=s.length()-1;i++)
    {
        if('0'<=s[i]&&s[i]<='9')
        {
            t=t+s[i];
        }
        else t="";
        res=maxx(res,t);
        //cout<<t<<endl;
    }
    cout<<res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    freopen("b.inp","r",stdin);
    freopen("b.OUT","w",stdout);
    cin>>s;
    giai();
}


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.