我修改了一些依然不行;
#include
#include
#include
char len='a'-'A';
void trans(char *a)
{
if((*a)>'Z'){*a=*a-len;}
} //将输入字母变成大写;
void check(char *p)
{trans(p);
char str1[27],str2[26];
char alph[26]={'A','B','C','D','E','F','G','H','I','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\0'};
int i,j;
i=0;
str1[i]=*p;
p++;
i++;
in:while(*p)
{trans(p);
for(j=0;j
{if(str1[j]==*p)
{p++;goto in;}
else continue;}
str1[i]=*p;i++;p++;
}; //将输入密钥中重复的字母去掉放在数组str1[]中;
if(!(*p))
{int k;
char *q;
int m=0;
q=alph;
on:while(*q)
{
for(k=0;k<=i;k++)
{if(*q==str1[k])
{q++;goto on;}
else continue;}
str2[m]=*q;q++;m++;
};
if(!(*q))
str2[m]='\0';
} //将alph数组中的字母按顺序放到str2中,如果其中有字母在str1中出现过就越过该字母;
strcat(str1,str2); //将str1和str2中的内容合并到str1中;
int n=0;
for(n=0;n<=25;n++)
cout<
}
void main()
{char buf[200];
cout<
scanf("%s",buf);
check(buf);
printf("\n");
char a ;
cin>>a;
}
这一部分主要是实现输入一个密钥,然后将其中重复的字母去掉,放入str1,然后把alph数组中在str1中没有出现的字母按照英文字母的顺序放入str2,最后把str2合并到str1中。
比如如果输入密钥是MONARCHY的话,结果应该是MONARCHYBDEFGIKLPQSTUVWXZ。
当我运行时出现Access violation,按确定出现47464544 ???
麻烦各位帮我看看是什么原因,谢谢了