64,567
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#define M 110
int main()
{
int t , i , j;
char a[M] ;
scanf("%d" , &t); //t组数据
for(int y=0;y <t;y++)
{
j=0;
i=0;
scanf("%s" , &a);
while(a[j] != '\0')
{
if(a[j] == 'B' && i == 0)
{
i++;
}
if(a[j] == 'U' && i==1)
{
i++;
}
if(a[j] == 'A' && (i == 2 || i == 3) )
{
i++;
}
j++;
}
if(i==4 && j!=4)
printf("Case %d: Yes\n" , y+1);
else
printf("Case %d: No\n" , y+1);
}
return 0;
}
http://acm.buaa.edu.cn/oj/problem_show.php?c=0&p=1018
我也觉得没错
但是提交的时候全是结果错误
郁闷。。
scanf("%s" ,&a);
改成scanf("%s",a)试试
#include <stdio.h>
#define M 110
int main()
{
int t , i , j;
char a[M] ;
scanf("%d" , &t); //t组数据
for(int y=0;y <t;y++)
{
j=0;
i=0;
scanf("%s" ,&a);
while(a[j] != '\0')
{
if(a[j] == 'B' && i == 0)
{
i++;
}
if(a[j] == 'U' && i==1)
{
i++;
}
if(a[j] == 'A' && (i == 2 || i == 3) )
{
i++;
}
j++;
}
if(i>=4)
printf("Case %d: Yes\n" , y+1);
else
printf("Case %d: No\n" , y+1);
}
return 0;
}
#include <stdio.h>
#define M 110
int main()
{
int t , i , j;
char a[M] ;
scanf("%d" , &t); //t组数据
for(int y=0;y <t;y++)
{
j=0;
i=0;
scanf("%s" ,&a);
while(a[j] != '\0')
{
if(a[j] == 'B' && i == 0)
{
i++;
}
if(a[j] == 'U' && i==1)
{
i++;
}
if(a[j] == 'A' && (i == 2 || i == 3) )
{
i++;
}
j++;
}
if(i>=4)
printf("Case %d: Yes\n" , y+1);
else
printf("Case %d: No\n" , y+1);
}
return 0;
}