-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy path10293.cpp
executable file
·60 lines (54 loc) · 1.05 KB
/
10293.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
/* Problem: Word Length and Frequency UVa 10293
Programmer: Md. Mahmud Ahsan
Description: Ad-hoc
Compiled: Visual C++ 7.0
Date: 17-08-06
*/
#include <iostream>
#include <string>
using namespace std;
int data[50];
void init(){
for (int i = 0; i < 50; ++i)
data[i] = 0;
}
int main(){
//freopen("input.txt", "r", stdin);
char ch, prev;
int i, j, len;
bool flag = false;
while (!cin.eof()){
init();
do{
len = 0;
ch = cin.get();
prev = ch;
if (cin.eof()) {
flag = true;
break;
}
while (ch!=' '&&ch!='?'&&ch!='!'&&ch!=','&&ch!='.'){
if (ch == '#') break;
if (ch == '\'' || ch == '-' || ch == '\n'){
if (ch == '\n' && prev != '-'){
break;
}
prev = ch;
ch = cin.get();
continue;
}
++len;
prev = ch;
ch = cin.get();
}
++data[len];
}while (ch != '#');
if (flag) break;
for (i = 1; i < 50; ++i){
if (data[i] != 0)
cout << i << " " << data[i]<< endl;
}
cout << endl;
}
return 0;
}