Codeforces Round #487 (Div. 2) A (题意题)

题意:总结下来就是看有没有连续的三个A,B,C顺序不限

思路:没有,,6个if就好了

上代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
	string ch;
	cin>>ch;
	int len = ch.size();
//	printf("%d\n",'A');
	for(int i = 0 ; i < len ; i++)
	{
		if(ch[i] == 'A')
		{
			if(ch[i+1] == 'B' && ch[i+2] == 'C')
			{
				puts("YES");
				return 0;
			}
			if(ch[i+1] == 'C' && ch[i+2] == 'B')
			{
				puts("YES");
				return 0;
			}
		}
		if(ch[i] == 'B')
		{
			if(ch[i+1] == 'A' && ch[i+2] == 'C')
			{
				puts("YES");
				return 0;
			}
			if(ch[i+1] == 'C' && ch[i+2] == 'A')
			{
				puts("YES");
				return 0;
			}
		}
		if(ch[i] == 'C')
		{
			if(ch[i+1] == 'B' && ch[i+2] == 'A')
			{
				puts("YES");
				return 0;
			}
			if(ch[i+1] == 'A' && ch[i+2] == 'B')
			{
				puts("YES");
				return 0;
			}
		}
		
	}
	puts("NO");
	return 0;	
}

猜你喜欢

转载自blog.csdn.net/wjmwsgj/article/details/80662120
今日推荐