-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva10008.cpp
68 lines (54 loc) · 939 Bytes
/
uva10008.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
60
61
62
63
64
65
66
67
68
using namespace std;
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<ctype.h>
struct structure
{
char c;
int ocr;
}alpha[30];
bool cmp(structure a,structure b)
{
if(a.ocr>b.ocr)
return true;
if(a.ocr==b.ocr)
return a.c<b.c;
return false;
}
int main()
{
char str[500];
int l,i,t,count[100],k;
for(i=60;i<100;i++)
count[i]=0;
cin>>t;
getchar();
while(t--)
{
gets(str);
l=strlen(str);
for(i=0;i<l;i++)
{
if(isalpha(str[i]))
count[toupper(str[i])]++;
}
}
k=0;
for(i=60;i<100;i++)
{
if(count[i]>0)
{
alpha[k].c=i;
alpha[k].ocr=count[i];
k++;
}
}
sort(alpha,alpha+k,cmp);
for(i=0;i<k;i++)
{
cout<<alpha[i].c<<" "<<alpha[i].ocr<<endl;
}
return 0;
}