-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (45 loc) · 856 Bytes
/
main.cpp
File metadata and controls
47 lines (45 loc) · 856 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
#include "node.h"
int main(){
PNode Head = NULL, p;
int cc = 0, max = 0;
ifstream in;
ofstream out;
string word;
in.open("input.txt"); // открываем
while (true) {
if (!in) break;
in >> word;
prov(word);
p = Find (Head, word); // ищем слово в списке
if (p != NULL){ // если нашли слово,
p->count++; // увеличить счетчик
if(p->count >= max){
max = p->count;
}
}else{
p = CreateNode(word); // создаем новый узел
AddLast (Head, p);
}
}
in.close();
p = Head;
out.open("output.txt");
for(int i = max; i > 0; --i){
p = Head;
if (cc >= 100){
break;
}
while(p){
if(cc <= 100){
if(p->count == i){
out << p->word << " - " << p->count << "\n";
++cc;
}
}else{
break;
}
p = p->next;
}
}
out.close();
}