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

哪位大牛帮我看看为什么WA?!!

Posted by ss08zhangchi at 2009-12-25 22:31:44 on Problem 1572 and last updated at 2010-01-19 16:26:39
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator