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 |
哪位大牛帮我看看为什么WA?!!#include <iostream> #include <string> using namespace std ; struct Rule { string find ; string replace_by ; } ; int main () { int i, N, pos ; Rule table[20] ; string text ; while (cin >> N && N != 0) { cin.sync () ; for (i = 0 ; i < N ; i++) { getline (cin, table[i].find) ; getline (cin, table[i].replace_by) ; } getline (cin, text) ; for (i = 0 ; i < N ; i++) { while ((pos = text.find (table[i].find)) >= 0 && pos < text.length ()) { text.replace (pos, table[i].find.length (), table[i].replace_by) ; } } cout << text << endl ; } return 0 ; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator