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

谁来帮帮我 为什么Runtime Error 啊

Posted by ylfdrib at 2009-08-24 16:10:05 on Problem 3087
#include<string>
#include<iostream>
#define N 102
using namespace std;

int ok, len;
void bfs(string s1, string s2, string s)
{
	int i;
	string s12;
	string::iterator it;
	it = s2.begin();
	for (i = 1; i <= len; i++)
	{
		s2.insert(it + 2 * i - 1, s1[i - 1]);
	}
	ok++;
	if (s2.compare(s) == 0)
		return;
	s12 = s2;
	do
	{
		s1 = s2.substr(0, len);
		s2 = s2.substr(len, len);
		it = s2.begin();
		for (i = 1; i <= len; i++)
		{
			s2.insert(it + 2 * i - 1, s1[i - 1]);
		}
		ok++;
		if (s2.compare(s) == 0)
			return;
	}
	while (s2.compare(s12) != 0);
	ok = -1;
}

int main()
{
	string s1, s2, s;
	int i, n;
	char a[2 * N], b[2 * N], c[2 * N];
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &len);
		scanf("%s%s%s", a, b, c);
		s1 = a;
		s2 = b;
		s = c;
		ok = 0;
		bfs(s1, s2, s);
		printf("%d %d\n", i, ok);
	}
	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