阴阳怪气的宿舍
阴阳怪气的宿舍
https://ac.nowcoder.com/acm/contest/10293/G
include <stdio.h>
include <string.h>
int main()
{
int i=0,flag=0,j=0,c1[5]= {0},c2[5]= {0},c3[5]= {0},p,max;
char s[5][1001];
for(i=0; i<5; i++)
scanf("%s",s[i]);
for(i=0; i<5; i++)
{
j=0;
while(s[i][j+6]!='\0')//遍历整个字符串,查找‘不是吧’
{
if(s[i][j]=='b'&&s[i][j+1]=='u'&&s[i][j+2]=='h'&&s[i][j+3]=='u'&&s[i][j+4]=='i'&&s[i][j+5]=='b'&&s[i][j+6]=='a')
{
c1[i]++;
j+=6;
}
j++;
}
j=0;
while(s[i][j+5]!='\0')//再遍历整个字符串,查找‘就这’
{
if(s[i][j]=='j'&&s[i][j+1]=='i'&&s[i][j+2]=='u'&&s[i][j+3]=='z'&&s[i][j+4]=='h'&&s[i][j+5]=='e')
{
c2[i]++;
j+=5;
}
j++;
}
}
for(i=0; i<5; i++)
{
c3[i]=c1[i]+c2[i];
if(i==0)
printf("qh %d %d\n",c1[i],c2[i]);
if(i==1)
printf("sh %d %d\n",c1[i],c2[i]);
if(i==2)
printf("hl %d %d\n",c1[i],c2[i]);
if(i==3)
printf("xx %d %d\n",c1[i],c2[i]);
if(i==4)
printf("kt %d %d\n",c1[i],c2[i]);
} max=c3[0]; p=0; for(i=1; i<5; i++)//找出最大的 if(c3[i]>max) { max=c3[i]; p=i; } i=p;//标记最大者的坐标
for(j=0; j<5; j++)//循环判断是否有和最大同大的
if(c3[j]==max)
flag++;
if(flag>1)
printf("yygqdss");
else{//利用标记变量输出最大的
if(i==0)
printf("qh");
if(i==1)
printf("sh");
if(i==2)
printf("hl");
if(i==3)
printf("xx");
if(i==4)
printf("kt");}
return 0;
}