-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuva-10062.cpp
More file actions
55 lines (43 loc) · 1016 Bytes
/
uva-10062.cpp
File metadata and controls
55 lines (43 loc) · 1016 Bytes
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
#include <bits/stdc++.h>
using namespace std;
struct ASCII
{
int value;
int freq;
bool operator<(const ASCII &op)
{
if (freq == op.freq) {
return value > op.value;
}
return freq < op.freq;
}
};
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
ASCII asc[127];
char text[10001];
int Len, i, j, test = 1;
while (gets(text)) {
Len = strlen(text);
for (i = 32; i <= 126; i++) {
asc[i].value = i;
asc[i].freq = 0;
}
for (i = 0; i < Len; i++) {
asc[(int) text[i]].freq++;
}
sort(asc + 32, asc + 127);
if (test != 1) {
printf("\n");
}
test++;
for (i = 32; i <= 126; i++) {
if (asc[i].freq != 0) {
printf("%d %d\n", asc[i].value, asc[i].freq);
}
}
}
return 0;
}