-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuva-10226.cpp
More file actions
65 lines (54 loc) · 1.33 KB
/
uva-10226.cpp
File metadata and controls
65 lines (54 loc) · 1.33 KB
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
char word[100], c;
int test, i, j, Len, total;
string name;
vector<string>trees;
scanf("%d", &test);
getchar();
getchar();
while (test--) {
//printf("test - %d\n", test);
while (true) {
c = getchar();
if (c == '\n' || c == EOF) {
break;
}
else {
ungetc(c, stdin);
}
gets(word);
//puts(word);
name = word;
trees.push_back(name);
}
sort(trees.begin(), trees.end());
Len = trees.size();
/*
for (i = 0; i < Len; i++) {
cout << i << " " << trees[i] << endl;
}
*/
total = 1;
for (i = 0; i < Len; i++) {
name = trees[i];
j = i + 1;
while (j < Len && trees[j] == name) {
total++;
j++;
}
printf("%s %.4lf\n", name.c_str(), (100.0 * total) / Len);
i = j - 1;
total = 1;
}
if (test) {
printf("\n");
}
trees.clear();
}
return 0;
}