[在线等] 加密 解密 问题
我用c语言写的,但是编译过了但是输出的结果是错的,为什么??#include<stdio.h>
#include <stdlib.h>
char * jiami1(char *s1,int *num)
{
char *t=s1;
int i;
for(;*s1!='\0';s1++)
{
if(*s1>='a'&&*s1<='z')
{
*s1=*s1+*num;
if(*s1>'z') *s1=*s1-25;
}
else if(*s1>='A'&&*s1<='Z')
{
*s1=*s1+*num;
if(*s1>'z') *s1=*s1-25;
}
}
return(t);
}
char * jiemi1(char *s1,int *num)
{
char *t=s1;
int i;
for(;*s1!='\0';s1++)
{
if(*s1>='a'&&*s1<='z')
{
*s1=*s1-*num;
if(*s1>'z') *s1=*s1+26;
}
else if(*s1>='A'&&*s1<='Z')
{
*s1=*s1-*num;
if(*s1>'z') *s1=*s1+26;
}
}
return(t);
}
main()
{char s1[100];
char *t;
char ch0;
int num;
printf("Please input the key:");
ch0=getchar();
num=(int)ch0;
printf ("num=%c\n",num);
{
printf("Please input the mingwen:");
scanf("%s",s1);
t=jiami1(s1,num);
printf("Miwen:%s\n",t);
printf("minwen:%s\n",jiemi1(t,num));
}
getch();
}
[[it] 本帖最后由 lemon6226 于 2008-10-15 16:30 编辑 [/it]]