Input
The input starts with the integer n on a line by itself - this is the number of strings to follow. The following n lines each contain one string of at most 50 upper-case letters.
|
Output
For each string in the input, first output the number of the string, as shown in the sample output. The print the string start is derived from the input string by replacing every time by the following letter in the alphabet, and replacing
'Z' by 'A'.
Print a blank line after each test case. |
Sample Input
2 HAL SWERC |
Sample Output
String #1 IBM String #2 TXFSD |
#include <stdio.h>
#include <string.h>
int main(){
char s[51];
int z, zz, len, i;
scanf("%d", &zz);
for (z=1; z<=zz; z++){
scanf("%s", s);
printf("String #%d\n", z);
len = strlen(s);
for (i=0; i<len; i++){
printf("%c", s[i]!='Z' ? s[i]+1 : 'A');
}
printf("\n\n");
}
return 0;
}
/**************************c语言************************/
初做题时,一直提示编译错误,可能我哪多个空行 回车一直报错 后来也没找到 今天索性贴出c(别人) c++代码。警示自己。
#include <iostream>
#include <string>
using namespace std;
int main()
{
long num,count;
string str;
cin>>num;
for(int i=1;i<=num;i++)
{
cin>>str;
//getline(cin,str);
for(count=0;count<str.length();count++)
{
if(str[count]=='Z')
str[count]='A';
else
str[count]=str[count]+1;
}
cout<<"String"<<'\t'<<"#"<<i<<'\n'<<str;
//if(i<num)
cout<<'\n'<<'\n';
//else cout<<'\n';
//str="0";
}
return 0;
}
c++**********************************************************************/