-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1035.cpp
More file actions
137 lines (132 loc) · 2.58 KB
/
1035.cpp
File metadata and controls
137 lines (132 loc) · 2.58 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
using namespace std;
typedef struct _word_t{
char contant[16];
int len;
}word_t;
int replace_check(char *check,char *word)
{
int flag=0;
while(*check){
if(*check!=*word){
flag++;
if(2==flag){
break;
}
}
check++;
word++;
}
return flag;
}
int insert_check(char *check,char *word)
{
int flag=0;
while(*check){
if(*check!=*word){
flag++;
word++;
if(2==flag){
break;
}
continue;
}else{
check++;
word++;
}
}
return flag;
}
int delete_check(char *check,char *word)
{
int flag=0;
while(*word){
if(*check!=*word){
flag++;
check++;
if(2==flag){
break;
}
continue;
}else{
check++;
word++;
}
}
return flag;
}
int main()
{
word_t dic[10001];
int i;
int word_cnt=0;
int similar[10001];
int simi_cnt=0;
char check[16];
int check_len;
cin>>dic[word_cnt].contant;
while(dic[word_cnt].contant[0]!='#'){
dic[word_cnt].len=strlen(dic[word_cnt].contant);
word_cnt++;
cin>>dic[word_cnt].contant;
}
cin>>check;
while(check[0]!='#'){
simi_cnt=0;
check_len=strlen(check);
for(i=0;i<word_cnt;i++){
switch(check_len-dic[i].len){
case 0:
switch(replace_check(check,dic[i].contant)){
case 0:
goto REPORT;
break;
case 1:
similar[simi_cnt++]=i;
break;
default:
break;
}
break;
case 1:
switch(delete_check(check,dic[i].contant)){
case 0:
similar[simi_cnt++]=i;
break;
case 1:
similar[simi_cnt++]=i;
break;
default:
break;
}
break;
case -1:
switch(insert_check(check,dic[i].contant)){
case 0:
similar[simi_cnt++]=i;
break;
case 1:
similar[simi_cnt++]=i;
break;
default:
break;
}
break;
default:
break;
}
}
REPORT:
if(i!=word_cnt){
cout<<check<<" is correct"<<endl;
}else{
cout<<check<<":";
for(i=0;i<simi_cnt;i++){
cout<<' '<<dic[similar[i]].contant;
}
cout<<endl;
}
cin>>check;
}
return 0;
}