您的位置:首页 > 其它

HDU - 4730 We Love MOE Girls

2016-07-18 08:41 357 查看
题目大意:结尾有 desu 的替换为 nanodesu,没有的直接在末尾加上 nanodesu

解题思路:检测覆盖

#include<iostream>
#include<cstdio>
#include<string.h>
#include<stdlib.h>
#include<cmath>
using namespace std;
int cnt = 0;
char str[1000];
char a[]="desu";
char b[]="nanodesu";
int main() {
int T;
scanf("%d", &T);
while (T--) {
memset(str, '\0', sizeof(str));
scanf("%s", str);
int len = strlen(str);
int tag = 1, j = 0;
for (int i = len - 4; i < len; i++) {
if (str[i] != a[j++]) tag = 0;
}
if(tag) {
j = 0;
for (int i = len - 4; j < 8;i++)
str[i] = b[j++];
}
else strcat(str,b);
printf("Case #%d: %s\n", ++cnt, str);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: