满意答案
houfji
2013.10.16
采纳率:40% 等级:12
已帮助:10430人
#include
int main(){
char a[80] ;
int s , n , i ;
printf("Enter message to be encrypted: \n");
for(i=0;;i++){
a[i]=getchar();
if(a[i]=='\n')break;
}
printf("Enter shift amount(1-25):\n");
scanf("%d",&s);
n=i;
for(i=0;i<=n;i++){
if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z'))
{
if(a[i]>='z'-s&&a[i]<='z'||a[i]>='Z'-s&&a[i]<='Z')
a[i]=a[i]-26+s;
else a[i]=a[i]+s;
}
}
printf("Encrypted message: ");
for(i=0;i<=n;i++)
printf("%c",a[i]);
return 0;
}
00分享举报