-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path10008.cpp
executable file
·59 lines (51 loc) · 904 Bytes
/
10008.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <cctype>
#include <string>
#include <algorithm>
using namespace std ;
class fre
{
public:
char v ;
int f ;
fre(){
f = 0 ;
}
static bool cmp( const fre &a, const fre &b )
{
if( a.f != b.f )
return a.f > b.f ;
else
return ( a.v -'A' ) < ( b.v -'A' ) ;
}
};
int main()
{
string buffer ;
fre c[ 26 ] ;
int t = 0 ;
int i = 0 ;
for( i = 0 ; i < 26 ; i++ )
{
c[ i ].v = 'A' + i ;
c[ i ].f = 0 ;
}
cin >> t ;
getline( cin, buffer ) ;
while( t > 0 )
{
t-- ;
getline( cin, buffer ) ;
for( i = 0 ; i < buffer.size() ; i++ )
{
if( isalpha( buffer[ i ] ) )
{
c[ toupper( buffer[ i ] ) - 'A' ].f += 1 ;
}
}
}
sort( c, c + 26, fre::cmp ) ;
for( i = 0 ; i < 26 && c[ i ].f > 0 ; i++ )
cout << c[ i ].v << " " << c[ i ].f << endl ;
return 0 ;
}