枚舉01

https://vjudge.net/problem/CodeForces-1097A
Input
AS
2H 4C TH JH AD
Output
YES
Input
2H
3D 4C AC KD AS
Output
NO
Input
4D
AS AC AD AH 5H
Output
YES
如果能找到和輸入一樣字符的輸出YES ,

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string s,a;
    int flag =0;
    cin>>s;
    for(int i=0; i<5; i++)
    {
        cin>>a;
        if(s[0]==a[0]||s[1]==a[1])
        {
            flag =1;
        }
    }
    if(flag == 1)
    cout<<"YES";
    else
    cout<<"NO";
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章