【蓝桥杯】2019:最长子序列

 while循环遍历

#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s1;
	string s2;
	cin>>s1>>s2;
	int i=0,j=0;
	int res=0;
	while(i<s1.size()&&j<s2.size())
	{
		if(s1[i]==s2[j])
		{
			i++;
			j++;
			res++;
		}
		else{
			i++;
		}
	}
	cout<<res;
	return 0;
	
 } 

猜你喜欢

转载自blog.csdn.net/m0_52043808/article/details/122864616
今日推荐