include fstream using namespace std ifstream cin segredo in ofstream c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <fstream>
using namespace std;
ifstream cin("segredo.in");
ofstream cout("segredo.out");
int main(){
char c;
int a[30],cnt=0;
for(int i=0;i<=30;i++){
a[i]=0;
}
int min=1001,max=0,max1=0;
while(!cin.eof()){
cin>>c;
a[int(c)-96]++;
if(max1<int(c)-96)max1=int(c)-96;
}
a[max1]--;
for(int i=1;i<=26;i++){
if(a[i]>0){
if(a[i]<min)min=a[i];
if(a[i]>max)max=a[i];
}
}
for(int i=1;i<=26;i++){
if(a[i]>0) if(a[i]==max)cout<<char(i+96);
}
cout<<endl;
for(int i=1;i<=26;i++){
if(a[i]>0) if(a[i]==min)cout<<char(i+96);
}
return 0;
}