| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用了一个老哥的数据改了之后AC了,感谢这位老哥```c++
/*
老哥的数据
hh
hjh
hhuh
hhu
#
hhu
uhh
huh
#
*/
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
string dic[10010];
string inp[60];
int d,p;
void step_1(string str);
void step_2(string str);
void step_1(string str)
{
int i;
for(i = 0; i < d; i++)
{
if(str.length() == dic[i].length())
{
int j = 0;
while(str[j] != 0)
{
if(str[j] == dic[i][j])
j++;
else
break;
}
if(j == str.length())
{
cout << " is correct" << endl;
return ;
}
}
}
step_2(str);
}
void step_2(string str)
{
int i;
int count[10001];
int time;
memset(count,0,sizeof(count));
cout << ":";
for(i = 0; i < d; i++)
{
int j = 0;
int t;
int k = 0;
time = 0;
if(dic[i].length() == str.length())
{
while(str[j] != 0)
{
if(dic[i][j] != str[j])
count[i]++;
j++;
}
if(count[i] == 1)
cout << " " << dic[i];
}
else if(dic[i].length() - str.length() == 1)
{
while(str[j] != 0)
{
for(t = k; t < dic[i].length(); t++)
if(str[j] == dic[i][t])
{
k = ++t;
time++;
break;
}
j++;
}
if(time == str.length())
cout << " " << dic[i];
}
else if(dic[i].length() - str.length() == -1)
{
while(dic[i][j] != 0)
{
for(t = k; t < str.length(); t++)
if(str[t] == dic[i][j])
{
time++;
k = ++t;
break;
}
j++;
}
if(time == dic[i].length())
cout << " " << dic[i];
}
}
cout << endl;
}
int main()
{
int i,j;
i = j = 0;
getline(cin,dic[i]);
while(dic[i][0] != '#')
{
getline(cin,dic[++i]);
}
d = i;
getline(cin,inp[0]);
while(inp[j][0] != '#')
{
getline(cin,inp[++j]);
}
p = j;
for(i = 0; i < p; i++)
{
cout << inp[i];
step_1(inp[i]);
}
return 0;
}
```
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator