【AtCoder】ABC104 AcCepted

题目

beta传送门

题目大意

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 个字符和倒数第2个字符之间(包括二者),恰好只有一个C(大写的)。

其他的两个条件:

  • 首字母是A
  • 字符串 S S 中出了AC没有别的大写字母。

字符串S只由大小写字母组成,符合上诉三个条件输出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");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值