-
Notifications
You must be signed in to change notification settings - Fork 0
/
4main.cpp
66 lines (57 loc) · 1.38 KB
/
4main.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
#include <iostream>
#include <cstring>
//#include <stdio.h>
#include <fstream>
using namespace std;
void func(char result[][100]);
int main()
{ int count = 1;
char result[100][100] = {0};
func(result);
for(int i = 0; strlen(result[i]); i++)
{
for(int j = i + 1; strlen(result[j]); j++)
{
int count = 1;
if(!strcmp(strlwr(result[i]), strlwr(result[j])))
{
count++;
}
}
cout << result[i] << '\t' << count <<endl;
}
return 0;
}
void func(char result[][100])
{
char buff[100];
ifstream in("D:\\A_Tale_of_Two_Cities.txt");
int j = 0;
char ch;
if(in)
{
in >> noskipws;
while(in >> ch)
{
int i = 0;
if(ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z')
{
buff[i++] = ch;
}
else
{
continue;
}
while(in >> ch && ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9')
{
buff[i++] = ch;
}
buff[i] = '\0';
if(strlen(buff) >= 1)//4
{
strcpy(result[j++],buff);
}
}
in.close();
}
}