C语言程序调试出错DEBUG ERROR 求大神
#include<stdio.h>#include<stdlib.h>#include<windows.h>#include<string.h>charrule1[4][...
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<string.h>
char rule1[4][5]={"DCBA","ADCB","BADC","CBAD"},rule2[4][5]={"DCAB","ABDC","BDCA","CABD"},rule3[4][5]={"DABC","ABCD","BCDA","CDAB"},rule4[4][5]={"DACB","ACBD","BDAC","CBDA"};
void main()
{
char fun(char b[],int i);
void moshu();
moshu();
}
void moshu()
{
char ch[4],an='E';
int i;
system("CLS");
tip2:scanf("%s",ch);
for(i=0;(i<4)&&(an=='E');i++)
{
an=fun(ch,i);
}
if(an=='E')
{
printf("输入有问题,请重新输入!\n");
system("pause");
system("CLS");
goto tip2;
}
printf("%c\n",an);
system("pause");
}
char fun(char b[],int i)
{
char bn='E';
if (strcmp(b,rule1[i])==0) bn='A';
if (strcmp(b,rule2[i])==0) bn='B';
if (strcmp(b,rule3[i])==0) bn='C';
if (strcmp(b,rule4[i])==0) bn='D';
return(bn);
} 展开
#include<stdlib.h>
#include<windows.h>
#include<string.h>
char rule1[4][5]={"DCBA","ADCB","BADC","CBAD"},rule2[4][5]={"DCAB","ABDC","BDCA","CABD"},rule3[4][5]={"DABC","ABCD","BCDA","CDAB"},rule4[4][5]={"DACB","ACBD","BDAC","CBDA"};
void main()
{
char fun(char b[],int i);
void moshu();
moshu();
}
void moshu()
{
char ch[4],an='E';
int i;
system("CLS");
tip2:scanf("%s",ch);
for(i=0;(i<4)&&(an=='E');i++)
{
an=fun(ch,i);
}
if(an=='E')
{
printf("输入有问题,请重新输入!\n");
system("pause");
system("CLS");
goto tip2;
}
printf("%c\n",an);
system("pause");
}
char fun(char b[],int i)
{
char bn='E';
if (strcmp(b,rule1[i])==0) bn='A';
if (strcmp(b,rule2[i])==0) bn='B';
if (strcmp(b,rule3[i])==0) bn='C';
if (strcmp(b,rule4[i])==0) bn='D';
return(bn);
} 展开
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<string.h>
char rule1[4][5]={"DCBA","ADCB","BADC","CBAD"},
rule2[4][5]={"DCAB","ABDC","BDCA","CABD"},
rule3[4][5]={"DABC","ABCD","BCDA","CDAB"},
rule4[4][5]={"DACB","ACBD","BDAC","CBDA"};
void main()
{
char fun(char b[],int i);
void moshu();
char fun(char b[],int i); //这句声明一下看看
moshu();
}
void moshu()
{
char ch[4],an='E';
int i;
system("CLS");
tip2:scanf("%s",ch);
for(i=0;(i<4)&&(an=='E');i++)
{
an=fun(ch,i);
}
if(an=='E')
{
printf("输入有问题,请重新输入!\n");
system("pause");
system("CLS");
goto tip2;
}
printf("%c\n",an);
system("pause");
}
char fun(char b[],int i)
{
char bn='E';
if (strcmp(b,rule1[i])==0) bn='A';
if (strcmp(b,rule2[i])==0) bn='B';
if (strcmp(b,rule3[i])==0) bn='C';
if (strcmp(b,rule4[i])==0) bn='D';
return(bn);
}
我用的VC6能运行
输入ABCD 出来C
BCDA C
DCBA A
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把该函数要放到main函数前面
char fun(char b[],int i)
{
char bn='E';
if (strcmp(b,rule1[i])==0) bn='A';
if (strcmp(b,rule2[i])==0) bn='B';
if (strcmp(b,rule3[i])==0) bn='C';
if (strcmp(b,rule4[i])==0) bn='D';
return(bn);
}
char fun(char b[],int i)
{
char bn='E';
if (strcmp(b,rule1[i])==0) bn='A';
if (strcmp(b,rule2[i])==0) bn='B';
if (strcmp(b,rule3[i])==0) bn='C';
if (strcmp(b,rule4[i])==0) bn='D';
return(bn);
}
追问
还是不对 一样的问题。。。。出现。。。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用strncmp(b,rule1[i],4)试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-28
展开全部
热个人网站不方便喜欢过提高
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询