DAF程序运行结果有问题, 求大神援助!!!
这里是我的代码
#include <stdio.h>
#include <malloc.h>
//////////////////////////////////////////////////
//////////Make a link list////////////////////////
//////////////////////////////////////////////////
typedef struct Node
{
char data;
struct Node *next;
}LNode,*LinkList;
//////////////////////////////////////////////////
//////////Save the input string in link list//////////
//////////////////////////////////////////////////
LinkList input()
{
LinkList L;
LNode *s,*r;
char x;
L=r=NULL;
scanf("%c",&x);
while(x!='#')
{
s=(LNode*)malloc(sizeof(LNode));
s->data=x;
if(L==NULL)
L=s;
else
r->next=s;
r=s;
scanf("%c",&x);
}
if(r!=NULL)
r->next=NULL;
return L;
}
/////////////////////////////////////////////////
/////////////////grammer///////////////
/////////////////////////////////////////////////
char nextview1(char a1,char a2)
{
char b='A';
{
if(a1 == 'A' && a2== 'a' )
b='B';
else if(a1 == 'A' && a2 == 'b' )
b='D';
else if(a1 == 'B' && a2 == 'a')
b='C';
else if(a1 == 'B' && a2 == 'b' )
b='D';
else if(a1 == 'C' && a2 == 'a' )
b='C';
else if(a1 == 'C' && a2 == 'b' )
b='C';
else if(a1 == 'D' && a2 == 'a' )
b='B';
else if(a1 == 'D' && a2 == 'b' )
b='E';
else if (a1 == 'E' && a2 == 'a' )
b='F';
else if (a1 == 'E' && a2 == 'b' )
b='E';
else if (a1 == 'F' && a2 == 'a' )
b='C';
else if (a1 == 'F' && a2 == 'b' )
b='E';
}
printf("stat is:\n",b);
return b;
}
////////////////////////////////////////////////////////
///////////judge string content the grammer or not ///////////////
///////////////////////////////////////////////////////
int move1(LinkList song)
{
char view;
view='A';
LNode *dou1;
dou1=song;
int i=0;
while(dou1!=NULL)
{
if(view!='E')
{
view=nextview1(view,dou1->data);
dou1=dou1->next;
}
else if(view!='F')
{
view=nextview1(view,dou1->data);
dou1=dou1->next;
}
else if(view=='E')
{
i=1;
}
else if(view=='F')
{
i=1;
}
}
printf("Display i :",i);
return i;
}
int main()
{
LinkList song;
int choose1,choose2;
int c;
printf("input your string (add # after you finish your input)\n");
song=input();
printf("DFA choice\n");
printf("1. grammer1\n");
/*printf("2. (a|b)﹡bbb﹡\n");*/
printf("2. EXIT\n");
while (c!=3)
{
switch (c)
{
case 1:
{
choose1=move1(song);
if(choose1==1)
{
printf("string accord grammer\n");
}
else
printf("string is not accord grammr\n");
break;
}
case 2:
{
c=4;
break;
}
}
scanf("%d",&c);
}
}
程序要求是检查输入的字符串是否符合程DFA定的语法 但是我每一次输出字符串 输出结果都是不符合 实在不知道原因, 而且在nextview1这个函数里 我想显示出STATE也显示不出来, 我在网上查过 我的输出语句应该是没问题的 ,希望大神能帮我解答
#include <stdio.h>
#include <malloc.h>
//////////////////////////////////////////////////
//////////Make a link list////////////////////////
//////////////////////////////////////////////////
typedef struct Node
{
char data;
struct Node *next;
}LNode,*LinkList;
//////////////////////////////////////////////////
//////////Save the input string in link list//////////
//////////////////////////////////////////////////
LinkList input()
{
LinkList L;
LNode *s,*r;
char x;
L=r=NULL;
scanf("%c",&x);
while(x!='#')
{
s=(LNode*)malloc(sizeof(LNode));
s->data=x;
if(L==NULL)
L=s;
else
r->next=s;
r=s;
scanf("%c",&x);
}
if(r!=NULL)
r->next=NULL;
return L;
}
/////////////////////////////////////////////////
/////////////////grammer///////////////
/////////////////////////////////////////////////
char nextview1(char a1,char a2)
{
char b='A';
{
if(a1 == 'A' && a2== 'a' )
b='B';
else if(a1 == 'A' && a2 == 'b' )
b='D';
else if(a1 == 'B' && a2 == 'a')
b='C';
else if(a1 == 'B' && a2 == 'b' )
b='D';
else if(a1 == 'C' && a2 == 'a' )
b='C';
else if(a1 == 'C' && a2 == 'b' )
b='C';
else if(a1 == 'D' && a2 == 'a' )
b='B';
else if(a1 == 'D' && a2 == 'b' )
b='E';
else if (a1 == 'E' && a2 == 'a' )
b='F';
else if (a1 == 'E' && a2 == 'b' )
b='E';
else if (a1 == 'F' && a2 == 'a' )
b='C';
else if (a1 == 'F' && a2 == 'b' )
b='E';
}
printf("stat is:\n",b);
return b;
}
////////////////////////////////////////////////////////
///////////judge string content the grammer or not ///////////////
///////////////////////////////////////////////////////
int move1(LinkList song)
{
char view;
view='A';
LNode *dou1;
dou1=song;
int i=0;
while(dou1!=NULL)
{
if(view!='E')
{
view=nextview1(view,dou1->data);
dou1=dou1->next;
}
else if(view!='F')
{
view=nextview1(view,dou1->data);
dou1=dou1->next;
}
else if(view=='E')
{
i=1;
}
else if(view=='F')
{
i=1;
}
}
printf("Display i :",i);
return i;
}
int main()
{
LinkList song;
int choose1,choose2;
int c;
printf("input your string (add # after you finish your input)\n");
song=input();
printf("DFA choice\n");
printf("1. grammer1\n");
/*printf("2. (a|b)﹡bbb﹡\n");*/
printf("2. EXIT\n");
while (c!=3)
{
switch (c)
{
case 1:
{
choose1=move1(song);
if(choose1==1)
{
printf("string accord grammer\n");
}
else
printf("string is not accord grammr\n");
break;
}
case 2:
{
c=4;
break;
}
}
scanf("%d",&c);
}
}
程序要求是检查输入的字符串是否符合程DFA定的语法 但是我每一次输出字符串 输出结果都是不符合 实在不知道原因, 而且在nextview1这个函数里 我想显示出STATE也显示不出来, 我在网上查过 我的输出语句应该是没问题的 ,希望大神能帮我解答
...全文
相关推荐
DAF2:下一版DAF
- **错误处理**:良好的错误处理机制,帮助开发者快速定位和解决问题。**4.
数据访问公共设施DAF
**专利提示** DAF的采纳者应注意,实施DAF规范时可能涉及到专利问题。尽管规范的发布者努力避免侵犯第三方的专利权,但不能保证完全规避所有潜在的专利侵权风险。
数据库--DAF数据库--DAF.ppt
数据访问设施(DAF): DAF是由ALSTOM ESCA提供的,它旨在解决不同系统之间的数据访问问题,使得控制中心应用编程接口(CCAPI)、公共数据访问(CDA)和其他系统能够通过统一的接口进行交互
MIMXRT1021DAF5A检测报告.zip
测试报告通常详细记录了MIMXRT1021DAF5A在功能、可靠性、环境适应性等方面的测试结果,帮助用户了解其性能稳定性和耐用性。
daf27-进阶2.sql
daf27-进阶2.sql


