麻烦大家啦
麻烦帮我看看为什么有这个错误、就是一个仿射密码的程序:#include <stdio.h>
struct affine
{
char letter;
int num;
};
struct affine aff={
{'a',0},{'b',1},{'c',2},{'d',3},{'e',4},{'f',5},{'g',6},{'h',7},{'i',8},{'j',9},{'k',10},{'l',11},{'m',12},{'n',13},
{'o',14},{'p',15},{'q',16},{'r',17},{'s',18},{'t',19},{'u',20},{'v',21},{'w',22},{'x',23},{'y',24},{'z',25}
};
void main()
{
char plaintext,cipher;
int k1,k2,k,i,j,l,len=0,num=0;
int number;
char c;
printf("Please input plaintext and end with '#':\n");
c=getchar();
while(c!='#')
{
plaintext=c;
num++;
c=getchar();
}
plaintext='\0';
len=num;
printf("The key is: \n");
scanf("%d%d",&k1,&k2);
//仿射操作
for(i=0,k=0;i<num;i++,k++)
{
for(j=0;j<26;j++)
{
if(plaintext==aff.letter)
{
number=(aff.num*k1+k2)%26;//出错的地方、
}
}
}
for(k=0,l=0;k<num;k++,l++)
{
for(j=0;j<26;j++)
{
if(number==aff.num)
{
cipher=aff.letter;
}
}
}
//转换成大写字母并输出密文
printf("The cipher is :");
for(l=0;l<num;l++)
{
cipher=cipher-32;
printf("%c",cipher);
}
printf("\n");
}
C:\Documents and Settings\Administrator\桌面\affine\affine.c(43) : error C2296: '*' : illegal, left operand has type 'int '
这么长的代码,鱼币太少 非常有用,谢谢了!
页:
[1]