ACM (TJU) : 2468


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

void reset (int *f)
{
    for ( int i = 0; i < 30; i++ )
    f [i] = 0;
}


int main ()
{
    int dataSet;
    cin >> dataSet;

    char a [150];


    while ( dataSet -- ) {

        cin >> a;

        int frq [30];
        reset (frq);

        for ( unsigned int i = 0; i < strlen (a); i++ )
        frq [a [i] - 97]++;

        int max = 0;

        for ( int i = 0; i < 30; i++ ) {
            if ( max < frq [i] )
            max = frq [i];
        }

        for ( int i = 0; i < 26; i++ ) {
            if ( max == frq [i] )
            printf ("%c", i + 97 );
        }

        printf ("\n");
    }

    return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s