Friday, April 28, 2017

UVA ONLINE JUDGE (PROBLEM: 11577)

UVA ONLINE JUDGE

(PROBLEM: 11577)



Solution::

#include<bits/stdc++.h>
using namespace std;
int
freq[30],t;
int main()
{


    char letter[30],a[210];

   scanf("%d\n",&t);
    while(t--)
    {  gets(a);
        int len=strlen(a);
    for(int i=0;i<26;i++)
    {
        letter[i]=i+97;
    }
        for(int i=0;i<len;i++)
        {
            a[i]=tolower(a[i]);
            for(int j=0;j<26;j++)
            {
                if(letter[j]==a[i])freq[j]++;
            }
        }
        int mx=-1;
        for(int i=0;i<26;i++)
        {
            if(freq[i]>mx) mx=freq[i];
        }
          for(int i=0;i<26;i++)
        {
            if(freq[i]==mx)
                printf("%c",letter[i]);
        }
         puts("");
    }
    return 0;

}

/* if you declare any variable outside of the main function,
  c compilers keeps 0 as it's initial value;
Than if you change or scan any value for this variable c compilers change the value as your
changing.*/



//Language:C++

No comments:

Post a Comment