编写加密代码的时候,第一个字符总是会变成乱码,但是取(3,3)时又可以正常运行,请教一下原因,谢谢
#include <stdio.h>
char secret (int k,int m,char cn);
int main (void)
{
int k,m;
char cn;
printf("k = ");
scanf("%d",&k);
printf("m = ");
scanf("%d",&m);
printf("Enter the sentence ended with # :\n");
while ( (cn = getchar()) != '#' )
{
if ( 32 <= cn && cn <= 126);
printf("%c",secret (k, m, cn));
}
putchar('/n');
return 0;
}
char secret (int k,int m,char cn)
{
int turn;
turn = cn;
turn = turn - 31;
turn = ( k * turn + m ) % 95 + 31;
cn = turn;
return cn;
}