| ||||||||||
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<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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator