Created
March 24, 2016 23:51
-
-
Save jianminchen/f35171b0c2ddcd403c2b to your computer and use it in GitHub Desktop.
Two string - C++ cin vs gets, scanf, while loop, pointer - calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cmath> | |
#include <algorithm> | |
#include <vector> | |
#include <queue> | |
#include <deque> | |
#define INF (1<<30) | |
#define mod 666013 | |
using namespace std; | |
int n, i, T, o, m, f[35]; | |
char b[100005], a[100005]; | |
int main() | |
{ | |
//freopen("1.in", "r", stdin); | |
//freopen("1.out", "w", stdout); | |
scanf("%d\n", &T); | |
while(T--) | |
{ | |
for(i=0;i<=30;i++) | |
f[i]=0; | |
gets(a+1); | |
gets(b+1); | |
n=strlen(a+1); | |
m=strlen(b+1); | |
for(i=1;i<=n;i++) | |
f[a[i]-'a']=1; | |
o=0; | |
for(i=1;i<=m;i++) | |
if(f[b[i]-'a']==1) | |
{ | |
printf("YES\n"); | |
o=1; | |
break; | |
} | |
if(o==0) | |
printf("NO\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment