#include
int main()
{
int i;
char str1[100],str2[100];
printf("input cipher code:");
gets(str1);
printf("\n cipher code :%s", str1);
for(i=0;str1[i]!='\0';i++)
if((str1[i]>=65)&&(str1[i]<=90))
str2[i]=155-str1[i];
else if((str1[i]>=97)&&(str1[i]<=122))
str2[i]=219-str1[i];
else
str2[i]=str1[i];
str2[i]='\0';//少了个结束标志
printf("\noriginal text:%s",str2);
return 0;
}
#include
int main()
{
int i;
char str1[100],str2[100];
printf("input cipher code:");
gets(str1);
printf("\ncipher code :%s", str1);
int i_end = 0;
for(i=0;str1[i]!='\0';i++)
{
i_end++;
if((str1[i]>=65)&&(str1[i]<=90))
str2[i]=155-str1[i];
else if((str1[i]>=97)&&(str1[i]<=122))
str2[i]=219-str1[i];
else
str2[i]=str1[i];
}
str2[i_end] = 0;
printf("\noriginal text:%s\n",str2);
return 0;
}
没有错误,我的机子上能显示正确的
你的程序的目的是什么?