CF1301A- Three Strings
对应位要么全相等,要么ac,bc有一个相等,ab不行。
1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 char a[110],b[110],c[110]; 5 int len,T; 6 bool suc; 7 bool check(char a,char b,char c) 8 { 9 if ((a == b && b == c) || (a == c) || (b == c)) 10 return true; 11 return false; 12 } 13 int main() 14 { 15 for (scanf("%d",&T);T;T--) 16 { 17 suc = true; 18 scanf("%s%s%s",a + 1,b + 1,c + 1); 19 len = strlen(a + 1); 20 for (int i = 1;i <= len;i++) 21 if (!check(a[i],b[i],c[i])) 22 { 23 suc = false; 24 break; 25 } 26 if (suc == true) 27 printf("YES\n"); 28 else 29 printf("NO\n"); 30 } 31 return 0; 32 }
心之所动 且就随缘去吧