Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 用了一个老哥的数据改了之后AC了，感谢这位老哥

Posted by xbmmp at 2020-04-02 22:07:19 on Problem 1035
``````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: