Construction and identification of finite automata 3

Source: Internet
Author: User

#include <stdio.h>#defineN 30Charstr[n]={NULL};intSt[n];intt=0, k=0, a,t1=0;structNode//Define a queue{    Chardata; structNode *next;}; typedefstructnode Queuenode;structNode2//define a chain queue{Queuenode*Front; Queuenode*rear;}; typedefstructNode2 Queue; Queue Initqueue ()//Initialize Queue{Queue Q; Q.front= (Queuenode *) malloc (sizeof(Queuenode)); Q.front->next=NULL; Q.rear=Q.front; return(Q);} Queue Inserq (Queue Q,CharX//x into the queue{Queuenode*p; P= (Queuenode *) malloc (sizeof(Queuenode)); P->data=x; P->next=NULL; Q.rear->next=p; Q.rear=p; return(Q);} Queue Deleteq (queue Q)//out Queue{    inti=t++, J; Queuenode*p; Chary; if(q.front==q.rear) {printf ("team listed, unable to get out of the queue! ");//determine if the queue is empty        return(Q); } P=q.front->Next; Y=q.front->next->data;//assigning elements in a queue to YQ.front->next=p->Next; if(p==q.rear) Q.rear=Q.front; Str[i]=y;//storing single charactersSt[k]=i;//Storage location    if(y==' '); if(y=='*'|| y=='|')    {        //if (y== ' * ')//str[i]=y;        if(str[0]!=null)//if the array str is not NULL, the outputPrint (0, str[0]); T=0; //continue;    }   /*if ((y>= ' A ' &&y<= ' Z ') | | (y>= ' A ' &&y<= ' Z '))   Use ASCII to determine if Y is a letter and stored in the array str {str[i]=y; }*/k++;    Free (p); returnQ;}voidPrint (intIChary);//call function to judge and outputMain () {Charx, y;    Queue p,q; P=Initqueue (); printf ("Please enter normal type:");  while(SCANF ("%c", &x) = =1&&x!='\ n')//the method of the great God, the oxp=Inserq (p,x); Q=p;  while(p.front!=p.rear) P=Deleteq (P); printf ("\ n The program was developed by Slag, not one of the group's representatives, thank you for using my program! \ n");}voidPrint (intICharY//call function to judge and output{a=st[i+1]+1; if(y=='|'|| y=='*') {k--; return; }    if(str[i]!='|') A=t1++; if(str[i+1]=='*') {printf ("f (%d,%c) =%d\n"I'~', K); printf ("f (%d,%c) =%d\n", k,y,k); printf ("f (%d,%c) =%d\n"K'~', a); }    Elseprintf ("f (%d,%c) =%d\n", i,y,st[i+1]); if(i<t) Print (i+1, str[i+1]); memset (str,0, N);//clears all elements in the array str}

Construction and identification of finite automata 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.