1203 construction of a poor automaton

Source: Internet
Author: User

It's an unfinished program.


#include <stdio.h> #include <string.h>char a[20][10];char vn[26];char vt[64];int m=0; int n=0; int m=0;int flag=-1;void Initial ()//³õê¼»¯{for (int b=0;b<26;b++) vn[b]= ' # '; for (int c=0;c<64;c++) vt[c]= ' # '; int d=0;d<20;d++) for (int e=0;e<10;e++) a[d][e]= ' # ';} void Group ()//åð¶ïöõ½á ûºå{for (int k=0;a[k][0]!= ' e '; k++) {for (int f=0;a[k][f]!= ' n '; f++) {if (a[k][f]>= ' a ') & & (a[k][f]<= ' Z ')) {for (int x=0;x<=m&&m<=27;x++) if (Vn[x]==a[k][f]) break;if ((x-1) ==m) {vn[m]=a[ K][F]; m++;}} else{for (int y=0;y<=n&&n<=20;y++) {if (a[k][f]== ': ' | | a[k][f]== ' = ') break;else{if (vt[y]==a[k][f]) break;}} if ((y-1) ==n) {vt[n]=a[k][f]; n++;}} }}}void input () {for (int i=0;i<10;i++) a[m][i]= ' # '; scanf ("%s", A[m]); (strcmp (A[m], "end") {if (a[m][0]>= ' A ') && (a[m][0]<= ' z ')) {int h=4;if ((a[m][h]>= ' a ') && (a[m][h]<= ' z ')) {if ((a[m][h+1]< ' a ') | | (a[m][h+1]> ' Z ')) {if (a[m][h+2]!= ') {printf ("´ë¹æôò²»êçõýôòîä ¨µä¹æôò£¬çëöøðâêäèë\n"); input (); break;}} Else {printf ("´ë¹æôò²»êçõýôòîä ¨µä¹æôò£¬çëöøðâêäèë\n"); input (); break;}} else {if (a[m][h+1]!= ')//u::=t{printf ("´ë¹æôò²»êçõýôòîä ¨µä¹æôò£¬çëöøðâêäèë\n"); input (); break;}}} M++;SCANF ("%s", A[m]);}} void Recongnise ()//åð¶ïêçè ¶¨»¹êç Çè ¶¨{for (int i=0;a[i][0]!= ' e '; i++) {for (int j=i+1;a[j][0]!= ' e '; j + +) {int n=4;if (a[i][n]==a[j][n]) n++;if (a[i][n]==a [j] [n]) break;} int h=4;if (a[i][h]==a[j][h]) h++;if (A[i][h]==a[j][h])//u::=t{printf ("´ëîä ¨¶ôó¦µäóðçîx´ì¬xô¶¯»úêç Çè ¶¨µä\n\n "); flag=0;break;}} if (a[i][0]== ' e ')//u::=wt{printf ("´ëîä ¨¶ôó¦µäóðçîx´ì¬xô¶¯»úêçè ¶¨µä\n\n"); flag=1;}} void output ()//êä³öîä ¨ïàó¦µäóðçîx´ì¬xô¶¯»ú{if (flag==0) {printf ("NFA n= ({)"); for (int i=0; vn[i]!= ' # '; i++) printf ("%c,", Vn[i]);p rintf ("s},{"); for (int j=0; vt[j]!= ' # '; j + +) printf ("%c,", Vt[j]);p rintf ("},m ', {s},{%c}) \ n", vn[0]);p rintf ("æäöðm ': \ n"); for (int x=0; vn[x]!= ' # '; x + +) {for (int y=0; vt[y]!= ' # '; y++) {printf ("M ' (%c,%c) =", vn[x],vt[y]); for (int z=0;a[z][0]!= ' e '; z++) if (a[z][4]==vn[x]) if (a[z][5]==vt[ Y]) printf ("%c", a[z][0]); if (a[z][0]== ' e ') printf ("\ t");} printf ("\ n");} for (int u=0; vt[u]!= ' # '; u++) {printf ("M ' (s,%c) =", Vt[u]); for (int k=0;a[k][0]!= ' e '; k++) if (A[k][4]==vt[u]) printf ("%c", a[k][0]); if (a[k][0]== ' e ') printf ("\ t");}} if (flag==1) {printf ("DFA n= ({)"); for (int b=0; vn[b]!= ' # '; b++) printf ("%c,", Vn[b]);p rintf ("s},{"); for (int c=0; vt[c]!= ' # '; C + +) printf ("%c,", Vt[c]);p rintf ("},m ', s,{%c}) \ n", vn[0]);p rintf ("æäöð:\n"); for (int p=0; vn[p]!= ' # ';p + +) {for (int q=0; vt[q]!= ' # '; q++) for (int r=0;a[r][0]!= ' # '; r++) if (A[r][4]==vn[p]) if (A[r][5]==vt[q]) printf ("M ' (%c,%c) =%c\t", Vn[p], Vt[q],a[r][0]);p rintf ("\ n");} for (int d=0; vt[d]!= ' # ';d + +) {for (int e=0;a[e][0]!= ' e '; e++) if (A[e][4]==vt[d]) printf ("M ' (s,%c) =%c\t", vt[d],a[e][0]);}}} void Main () {initial ();p rintf ("Çëêäèëîä ¨£¨òôend½áêø£©:\n"), input (), group ();p rintf ("\ n"); recongnise (); output (); printf ("\ n");}

  

1203 construction of a poor automaton

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.