题目
题目大意
AC
WA
WA
WA
There is exactly one occurrence of
C
between the third character from the beginning and the second to last character (inclusive).
这句话简直要人命……目前尚未发现有翻译软件翻译正确= =
正确翻译方式:
from the beginning限定the third character,to last character限定the second,between…and限定
C
也就是说:
- 在正数第
3
3
个字符和倒数第个字符之间(包括二者),恰好只有一个
C
(大写的)。
其他的两个条件:
- 首字母是
A
。 - 字符串
S
S
中出了
A
和C
没有别的大写字母。
字符串只由大小写字母组成,符合上诉三个条件输出AC
,否则输出WA
。
分析
见题目大意。
代码
#include<cstdio>
#include<cstring>
char str[15];
int main(){
scanf("%s",str+1);
int len=strlen(str+1),cnt=0;
if(str[1]!='A'||str[2]=='C'||str[len]=='C'){
puts("WA");
return 0;
}
for(int i=3;i<=len-1;i++){
if(str[i]=='C'){
if(cnt){
puts("WA");
return 0;
}
cnt++;
}
}
if(!cnt){
puts("WA");
return 0;
}
for(int i=2;i<=len;i++){
if(str[i]=='C') continue;
if(str[i]<'a'||str[i]>'z'){
puts("WA");
return 0;
}
}
puts("AC");
}