|
1鱼币
麻烦帮我看看为什么有这个错误、 就是一个仿射密码的程序:
#include <stdio.h>
struct affine
{
char letter[26];
int num[26];
};
struct affine aff[26]={
{'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[100],cipher[100];
int k1,k2,k,i,j,l,len=0,num=0;
int number[26];
char c;
printf("Please input plaintext and end with '#':\n");
c=getchar();
while(c!='#')
{
plaintext[num]=c;
num++;
c=getchar();
}
plaintext[num]='\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[i]==aff[j].letter)
{
number[k]=(aff[j].num*k1+k2)%26;//出错的地方、
}
}
}
for(k=0,l=0;k<num;k++,l++)
{
for(j=0;j<26;j++)
{
if(number[k]==aff[j].num)
{
cipher[l]=aff[j].letter;
}
}
}
//转换成大写字母并输出密文
printf("The cipher is :");
for(l=0;l<num;l++)
{
cipher[l]=cipher[l]-32;
printf("%c",cipher[l]);
}
printf("\n");
}
C:\Documents and Settings\Administrator\桌面\affine\affine.c(43) : error C2296: '*' : illegal, left operand has type 'int [26]'
|
|