网上几乎没有1035的代码
这个代码在vector输入的时候有问题
求大神指点
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
vector <string> dict;
vector <string> cmp;
bool eql(int a)
{
int i = dict.size();
while(i--)
{
if(cmp[a]==dict[i])
return true;
}
return false;
}
bool subtract (int a,int b)
{
string tmp;
if(cmp[a].size()-1 == dict[b].size())
for(int i = 0; i < cmp[a].size();i++)
{
tmp = cmp[a];
tmp.erase(i,1);
if(tmp == dict[b])
{
cout <<" "<< tmp;
return true;
}
}
else
return false;
}
bool repalcing (int a, int b)
{
if (dict[b].size() == cmp[a].size())
{
int recording;
for (int i = 0; i < dict[b].size(); i++)
{
if (dict[b][i] == cmp[a][i])
{
;
}
else
{
recording = i;
break;
}
}
for (int i = recording+1; i < dict[b].size(); i++)
{
if (dict[b][i] == cmp[a][i])
{
;
}
else
return false;
}
string ss = cmp[a];
ss.erase(recording,1);
cout <<" "<<ss;
return true;
}
else
return false;
}
bool inserting (int a,int b)
{
if(cmp[a].size() == dict[b].size()-1)
for(int i = 0; i < cmp[a].size();i++)
{
string tmp = dict[b];
tmp.erase(i,1);
if(tmp == cmp[a])
{
cout <<" "<< tmp;
return true;
}
}
else
return false;
}
int main ()
{
for (int i = 0; i < 10001; i++)
{
scanf("%s",dict[i]);printf("sdf");
if(dict[i] == "#")
break;
}
for (int i = 0; i < 51; i++)
{
cin >>cmp[i];
if(cmp[i] == "#")
break;
}
for (int i = 0; i < cmp.size(); i++)
{
if (eql(i))
{
cout << cmp[i] << " is correct";
}
else
for (int ii = 0; ii< dict.size();ii++)
{
cout <<":"<<cmp[i];//注意分函数输出前加空格
if(subtract(i,ii))
continue;
else if(repalcing(i,ii))
continue;
else if(inserting(i,ii))
continue;
else
;
}
}
return 0;
}