| ||||||||||
| 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 | |||||||||
总是Runtime Error,求指教!#include <iostream>
#include <cstring>
#include <string>
#include <fstream>
#include <memory.h>
#include <cmath>
using namespace std;
int main()
{
ifstream input;
input.open("x.txt");
string x[10001];
string y[51];
int i;
int long_c[50];
bool check[10000];
int num_d = 0;
int num_c = 0;
int diff = 0;
int k = 0;
int h = 0;
bool isFind = 0;
while(1)
{
fflush(stdin);
input >> x[num_d];
if(x[num_d] != "#")
num_d++;
else
break;
}
while(1)
{
fflush(stdin);
input >> y[num_c];
if(y[num_c] != "#")
num_c++;
else
break;
}
input.close();
for(i = 0;i < num_c;i++)
long_c[i] = y[i].length();
for(i = 0;i < num_c;i++)
{
memset(check,0,sizeof(check));
isFind = 0;
for(int j = 0;j < num_d;j++)
{
if(y[i] == x[j])
{
isFind = 1;
y[i] += " is correct";
break;
}
if(long_c[i] - x[j].length() == 1 || long_c[i] - x[j].length() == -1 || long_c[i] == x[j].length())
{
check[j] = 1;
}
}
if(isFind == 1)
continue;
y[i] += ":";
for(int j = 0;j < num_d;j++)
{
if(check[j] == 1)
{
diff = 0;
if(long_c[i] == x[j].length())
{
k = 0;
while(k < long_c[i])
{
if(y[i][k] != x[j][k])
diff++;
k++;
}
}
else if(long_c[i] - x[j].length() == 1)
{
k = 0;
h = 0;
while(k < long_c[i])
{
if(h == x[j].length())
diff++;
else if(x[j][h] != y[i][k])
{
diff++;
k++;
}
else
{
h++;
k++;
}
}
}
else
{
k = 0;
h = 0;
while(k < x[j].length())
{
if(h == long_c[i])
diff++;
else if(x[j][k] != y[i][h])
{
diff++;
k++;
}
else
{
h++;
k++;
}
}
}
if(diff == 1)
{
y[i] += " ";
y[i] += x[j];
}
}
}
}
ofstream output;
output.open("y.txt");
for(int i = 0;i < num_c;i++)
output << y[i] << endl;
output.close();
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator