题目:“将“program”译成密码并输出。密码规律:由用户任意输入一个0——10之间的数i,生成密码由原字母对应的小写字母后的第i个字母代替。”
#include<iostream>
using namespace std;
int main()
{
int i;
char test[] = "program";
char *p = test;
cout<<"input a number 0~10:";
cin>>i;
while(*p != '\0') {
*p += i;
++p;
}
cout<<test<<endl;
return 0;
}
using namespace std;
int main()
{
int i;
char test[] = "program";
char *p = test;
cout<<"input a number 0~10:";
cin>>i;
while(*p != '\0') {
*p += i;
++p;
}
cout<<test<<endl;
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2013-09-24
char test[] = "program";
cin>>i;
test[i] +=i;
cin>>i;
test[i] +=i;
第2个回答 2013-09-24
没明白,如果输入3 表示 就是pr3gram?