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

Re:自己测试的数据都正确，可一直wa，求解啊！！

Posted by chitongyu at 2016-12-11 01:06:46 on Problem 1458
In Reply To:自己测试的数据都正确，可一直wa，求解啊！！ Posted by:MiracleCheng at 2016-08-16 12:51:34
```> #include <iostream>
> using namespace std;
> int main()
> {
> 	int count;
> 	int loc;
> 	int cmp;
> 	const int maxn = 10000;
> 	char x[maxn], y[maxn];
> 	while (cin >> x >> y)
> 	{
> 		loc = 0;//相等的位置location
> 		count = 0;//计数
> 		int xlen = strlen(x);//求字符长度
> 		int ylen = strlen(y);
> 		//从y字符串开始搜索
> 			for (int i = 0; i < ylen; i++)
> 			{
>
> 				for (int j = loc; j < xlen; j++)
> 				{
>
> 					if (x[j] == y[i])
> 					{
> 						loc = j + 1;
>
> 						count++;
> 						break;
>
> 					}
>
> 				}
> 			}
> 			cmp = count;//数据初始化
> 			count = 0;
> 			loc = 0;
> 			//从x字符串开始搜索
> 			for (int i = 0; i < xlen; i++)
> 			{
>
> 				for (int j = loc; j < ylen; j++)
> 				{
>
> 					if (x[i] == y[j])
> 					{
> 						loc = j + 1;
>
> 						count++;
> 						break;
>
> 					}
>
> 				}
> 			}
> 			if (count>=cmp)//输出较大的
> 				cout << count << endl;
> 			else
> 				cout << cmp << endl;
> 	}
>
>
> 	return 0;
> }
```

Followed by: