C语言作业谁能帮我看看这个翻译凯撒密码的哪里有问题
#include<stdio.h>intmain(){chara[80];ints,n,i;printf("Entermessagetobeencrypted:\n");...
#include <stdio.h>
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;
}
#include <stdio.h>
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;
}
刚才那个有点问题 但改成这样也不管 展开
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;
}
#include <stdio.h>
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;
}
刚才那个有点问题 但改成这样也不管 展开
2个回答
展开全部
#include <stdio.h>
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;
}
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询