题目描述
There was a boy called ZDD, and he loved a girl whose name is SZD. They loved each other deeply. After saving SZD from TIANKENG, they led a happy life. And later they had a son, and choosing name of their son was a big problem. ZDD was very like “ABB” style. For example, “ZhaoDongDong” is a “ABB” style name, and “ChenLiJian” is not. Then ZDD wanted to know if a name was “ABB” style or not?
Note that A and B should be different!
输入
The first line is an integer T, which indicates the number of test case.
For each test case, there is a string S, which indicates the name of their son. The length of the string is not more than 100. The first letter of every word will be capital.Besides, the name string only contains uppercase and lowercase letters.
输出
For each test case, if the name is “ABB” style output “Yes”, otherwise output “No” in one line.
样例输入
样例输出
#include <stdio.h>
#include <string.h>
char k[30],a[10],b[10],c[10];//K数组为原始姓名字符串
int h[5];//用来标记大写字母位置,用来把姓名拆分成3部分
int main()
{int n,i,m,s,l;scanf("%d",&n);for(i=0;i<n;i++){for(s=0;s<10;s++) a[s]='\0',b[s]='\0',c[s]='\0';//多组,初始化 scanf("%s",k);m=0;for(s=1;s<strlen(k);s++){if(k[s]>='A'&&k[s]<='Z') h[m]=s,m++; //确定大写字母位置,开头字母一定为大写,我们就从第二位开始 }for(s=0;s<h[0];s++) a[s]=k[s]; //姓 l=0;for(s=h[0];s<h[1];s++) b[l]=k[s],l++; //名1 l=0;for(s=h[1];s<strlen(k);s++) c[l]=k[s],l++; //名2 if(strcmp(a,b)!=0&&strcmp(a,c)!=0&&strcmp(b,c)==0){ //判断 printf("Yes\n");}else{printf("No\n");}}return 0;
}