您的位置:首页 > 其它

HDU 4730 We Love MOE Girls

2013-09-14 17:49 260 查看
   ps( Forgive  my poor English .....Bear with the dermination of a study of slag.....) 

   Today , I participate in  the 2013
ACM/ICPC Asia Regional Chengdu Online !

   I  just worked out two problems ------the 1003 and the 1010 . Just as you konw, they are the simple problems.

     the details about the problem are followed.

  


We Love MOE Girls

Problem Description

Chikami Nanako is a girl living in many different parallel worlds. In this problem we talk about one of them.
In this world, Nanako has a special habit. When talking with others, she always ends each sentence with "nanodesu".
There are two situations:
If a sentence ends with "desu", she changes "desu" into "nanodesu", e.g. for "iloveyoudesu", she will say "iloveyounanodesu". Otherwise, she just add "nanodesu" to the end of the original sentence.
Given an original sentence, what will it sound like aften spoken by Nanako?


[b]Input
[/b]

The first line
has a number T (T <= 1000) , indicating the number of test cases.
For each test case, the only line contains a string s, which is the original sentence.
The length of sentence s will not exceed 100, and the sentence contains lowercase letters from a to z only.


[b]Output
[/b]

For
every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1. Then output
which Nanako will say.


My code:

#include <stdio.h>
#include <string.h>

int main()
{
const int size = 120;
int t,len,i,j;
char word[ size ];
char s[5];
const char ch[] = "nanodesu"; //将要添加的后缀
scanf("%d",&t);
for(int k=0;k<t;k++)
{
scanf("%s",word);
len = strlen(word);
memset(s,0,sizeof(s));
if(len>=4)   //如果字符串长度大于4才需要判断desu;
{
for(i=len-4,j=0;i<len;i++,j++)
s[j]=word[i];
s[5] = '\0';
}

if(!strcmp("desu",s))
{
strcpy(word+len-4,ch);
}
else strcat(word,ch);
printf("Case #%d: %s\n",k+1,word);
}

}


0Ms pass.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  acm simple