HDU 4730 We Love MOE Girls(签到题 string char)
来源:互联网 发布:淘宝新店没流量 编辑:程序博客网 时间:2024/05/02 02:31
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4730
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?
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?
Input
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.
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.
Output
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.
Sample Input
2ohayougozaimasudaijyoubudesu
Sample Output
Case #1: ohayougozaimasunanodesuCase #2: daijyoubunanodesu
Source
2013 ACM/ICPC Asia Regional Chengdu Online
代码如下:
string
#include <cstdio>#include <cstring>#include <string>#include <iostream>#include <algorithm>using namespace std;string s, s1, s2;int main(){ int t; int cas = 0; cin >> t; while(t--) { printf("Case #%d: ",++cas); cin >> s; int len = s.length(); if(len < 4) { cout<<s<<"nanodesu"<<endl; continue; } s1 = s.substr(len-4,4); s2 = s.substr(0,len-4); if(s1 == "desu") { cout<<s2<<"nanodesu"<<endl; } else { cout<<s<<"nanodesu"<<endl; } } return 0;}/*99aabbohayougozaimasudaijyoubudesudesudesudesuddddd*/
char
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;char s[117],s1[117];int main(){ int t; int cas = 0; scanf("%d",&t); while(t--) { scanf("%s",s); int len = strlen(s); for(int i = 0; i < len-4; i++) { s1[i] = s[i]; } s1[len-4] = '\0'; printf("Case #%d: ",++cas); if(s[len-4]=='d'&&s[len-3]=='e'&&s[len-2]=='s'&&s[len-1]=='u') { //if(len != 4) printf("%s",s1); printf("nanodesu\n"); } else { printf("%s",s); printf("nanodesu\n"); } } return 0;}
0 0
- HDU 4730 We Love MOE Girls(签到题 string char)
- 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
- 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
- C++入门经典 笔记 (第十一章)开发高级指针
- Hexo博客网站再配置
- UVALive 5103 / HDU 3695 Computer Virus on Planet Pandora(AC自动机裸)
- Next Permutation
- 排序与查找
- HDU 4730 We Love MOE Girls(签到题 string char)
- wstring 未定义的标识符,include <string>
- js跨域问题
- Android SDK不能在线更新的解决方案
- 阅兵
- 使用Ajax加载数据的dataTables
- jpa复合主键的使用
- hdoj 4686 Arc of Dream 【矩阵快速幂】
- CvvImage类