(3)IBM Minus One

 
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++**********************************************************************/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值