Thursday, May 18, 2017

UVa online jude 12543

UVa online judge
problem:12543
(longest word)

 problem(PDF):

Solution:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    string a,b;
    int mx=0,c;
    for(int i=0;; i++)
    {
        cin>>a;
        if(a=="E-N-D") break;
        c=0;
        for(int j=0; j<a.size(); j++)
            if(islower(a[j])||isupper(a[j])||a[j]=='-') c++;

        if(c>mx)
        {
            mx=c;
            b=a;
        }
    }
    for(int j=0; j<b.size(); j++)
        if(islower(b[j])||isupper(b[j])||b[j]=='-')
        {
            if(isupper(b[j])) b[j]=tolower(b[j]);
            printf("%c",b[j]);
        }
      puts("");
      return 0;
}

 

No comments:

Post a Comment