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

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:

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