#include<bits/stdc++.h>
using namespace std;
void bubble(int a[], int b[])
{
int i, j;
for(i=0; i<26-1; i++)
{
for(j=0; j<26-i-1; j++)
{
if(a[j] < a[j+1])
{
swap(a[j], a[j+1]);
swap(b[j], b[j+1]);
}
}
}
}
int main()
{
int num1[26], num2[26], big[26], sm[26];
string s;
int i, j, k;
while(getline(cin, s))
{
for(i=0; i<26; i++)
num1[i] = num2[i] = 0;
j = 65;
for(i=0; i<26; i++)
{
big[i] = j;
j++;
}
j = 97;
for(i=0; i<26; i++)
{
sm[i] = j;
j++;
}
int l = s.size();
for(i=0; i<l; i++)
{
if(s[i] >= 'A' && s[i] <= 'Z')
{
int t = s[i] - 65;
num1[t] += 1;
}
if(s[i] >= 'a' && s[i] <= 'z')
{
int t = s[i] - 97;
num2[t] +=1;
}
}
bubble(num1, big);
bubble(num2, sm);
vector<char>v;
int t = 0;
if(num1[0] >= num2[0])
{
t = num1[0];
i = j = 0;
while(num1[i] == t && i < 26)
{
char ch = big[i];
v.push_back(ch);
i++;
}
while(num2[j] == t && j < 26)
{
char ch = sm[j];
v.push_back(ch);
j++;
}
}
else if(num1[0] < num2[0])
{
t = num2[0];
j = 0;
while(num2[j] == t && j < 26)
{
char ch = sm[j];
v.push_back(ch);
j++;
}
}
for(i=0;i<v.size();i++)
cout << v[i];
cout << " " << t << endl;
}
return 0;
}
using namespace std;
void bubble(int a[], int b[])
{
int i, j;
for(i=0; i<26-1; i++)
{
for(j=0; j<26-i-1; j++)
{
if(a[j] < a[j+1])
{
swap(a[j], a[j+1]);
swap(b[j], b[j+1]);
}
}
}
}
int main()
{
int num1[26], num2[26], big[26], sm[26];
string s;
int i, j, k;
while(getline(cin, s))
{
for(i=0; i<26; i++)
num1[i] = num2[i] = 0;
j = 65;
for(i=0; i<26; i++)
{
big[i] = j;
j++;
}
j = 97;
for(i=0; i<26; i++)
{
sm[i] = j;
j++;
}
int l = s.size();
for(i=0; i<l; i++)
{
if(s[i] >= 'A' && s[i] <= 'Z')
{
int t = s[i] - 65;
num1[t] += 1;
}
if(s[i] >= 'a' && s[i] <= 'z')
{
int t = s[i] - 97;
num2[t] +=1;
}
}
bubble(num1, big);
bubble(num2, sm);
vector<char>v;
int t = 0;
if(num1[0] >= num2[0])
{
t = num1[0];
i = j = 0;
while(num1[i] == t && i < 26)
{
char ch = big[i];
v.push_back(ch);
i++;
}
while(num2[j] == t && j < 26)
{
char ch = sm[j];
v.push_back(ch);
j++;
}
}
else if(num1[0] < num2[0])
{
t = num2[0];
j = 0;
while(num2[j] == t && j < 26)
{
char ch = sm[j];
v.push_back(ch);
j++;
}
}
for(i=0;i<v.size();i++)
cout << v[i];
cout << " " << t << endl;
}
return 0;
}
Comments
Post a Comment