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;
}
//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;
}
thanks a lot.
ReplyDeleteimport java.io.*;
ReplyDeleteimport 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.
use this if((charstr[0]==charstr1[0]) || (charstr[1]==charstr1[1]))
Delete