|
|
вернуться в форумWhy is WA4?(Please help) #include <iostream> #include <vector> #include <string> #include <cstring> #include <string.h> #include <fstream> using namespace std; struct our { char a[10]; }; char temp[10]; our V[105]; int SizeV; int main() { freopen("output.txt","w",stdout); freopen("input.txt","r",stdin); bool doit = true; int SizeV = -1; while(doit) if(strlen(temp) == 1 && temp[0] == '#') doit = false; else { ++SizeV; for(int k = 0; k < strlen(temp); k++) V[SizeV].a[k] = temp[k]; cin >> temp; } char a; char word[105]; int fails = 0; string s; getline(cin,s); char r; while(getline(cin,s)) { if(s.size() != 0) { int i = 0; char word[10]; while(i < s.size()) { int wordind = -1; while(s[i] >= 'a' && s[i] <= 'z') { word[++wordind] = s[i]; i++; } bool done = false; int nuz = 0; for(int j = 0; j <= SizeV; j++) { int error = 0; if((wordind+1) == strlen(V[j].a)) { for(int k = 0; k <= wordind; k++) if(word[k] != V[j].a[k]) { error++; if(error > 1) break; } if(error == 1) { done = true; nuz = j; fails++; break; } } } if(done) for(int e = 0; e < strlen(V[nuz].a); e++) cout << V[nuz].a[e]; else for(int e = 0; e <= wordind; e++) cout << word[e]; cout << s[i++]; } } cout << endl; } cout << fails << endl; fclose(stdin); fclose(stdin); return 0; } Edited by author 09.07.2014 20:44 |
|
|