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.
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:
0Ms pass.
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 DescriptionChikami 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.
相关文章推荐
- HDU-4730 We Love MOE Girls
- hdu 4730 We Love MOE Girls(水题)
- Hdu 4730 We Love MOE Girls
- HDU 4730 We Love MOE Girls
- 2013成都网赛1003 hdu 4730 We Love MOE Girls
- HDU - 4730 We Love MOE Girls 水题
- HDU 4730 We Love MOE Girls (2013成都网络赛,签到水题)
- HDU 4730 We Love MOE Girls
- HDU - 4730 We Love MOE Girls
- HDU 4730 We Love MOE Girls
- hdu 4730 We Love MOE Girls(字符串:水题)
- HDU 4730 We Love MOE Girls
- HDU 4730-We Love MOE Girls
- HDU-#4730 We Love MOE Girls(字符串)
- HDU 4730 We Love MOE Girls
- HDU 4730 We Love MOE Girls 解题报告
- HDU - 4730 We Love MOE Girls
- HDU 4730 We Love MOE Girls(签到题 string char)
- hdu 4730 We Love MOE Girls
- hdu 4730 We Love MOE Girls