Codeforces 1097A. Gennady and a Card Game Solution

Solve in C++:

//AH Tonmoy
//Department of CSE ,Islamic University
#include<bits/stdc++.h>
using namespace  std;
int main()
{
    int c=0,i;
    string s,s1;
    cin>>s;
    for(i=0; i<5; i++)
    {
        cin>>s1;
        if((s[0]==s1[0])||(s[1]==s1[1]))
            c++;
    }
    if(c>0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}

3 comments:

  1. import java.io.*;
    import java.util.*;
    public class Cards
    {
    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);
    int T=sc.nextInt();
    while(T!=0)
    {
    String str,str1;
    int c=0;
    str= sc.next();
    char[] charstr=str.toCharArray();
    for(int i=0; i<5; i++)
    {
    str1=sc.next();
    char[] charstr1=str1.toCharArray();
    if((str[0]==str1[0]) || (str[1]==str1[1]))
    c++;
    }
    if(c>0)
    System.out.println("YES");
    else
    System.out.println("NO");
    T--;
    }
    }
    }
    i'm getting error in if part... can you help me out.

    ReplyDelete
    Replies
    1. use this if((charstr[0]==charstr1[0]) || (charstr[1]==charstr1[1]))

      Delete

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.