http://acm.hdu.edu.cn/showproblem.php?pid=4730
直接用string类处理字符串。
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring> using namespace std; int main()
{
int t,k,n,i;
string s,p;
scanf("%d",&t);
k = 0;
while(t--)
{
k++;
cin>>s;
n = s.length();
if(s[n-1]=='u'&&s[n-2]=='s'&&s[n-3]=='e'&&s[n-4]=='d')
{
s.erase(n-4,n); //删掉最后4个字符
s+="nanodesu";
}
else
{
s+="nanodesu";
}
printf("Case #%d: ",k);
cout<<s<<endl;
} return 0;
}