1#include <stdio.h>2 Main ()3 {4 intI=0, j=0, x=0, y;5 intNumber=2;6 intCount=0;7 Charch;8 Chara[ -][ -];9printf"Please enter regular formula to end with #: \ n");Tenprintf"^ represents empty \ n"); Oneprintf"| delegate or \ n"); ACh=GetChar (); - Do - { the if(ch=='|') - { -a[i][j]=' /'; -j=0; +i++; -Ch=GetChar (); + Continue; A } ata[i][j]=ch; -J + +; -Ch=GetChar (); -} while(ch!='#'); -a[i][j]=' /'; - for(x=0; x<=i;x++) in { -y=0; toCount=1; + while(a[x][y]!=' /') - { the if(a[x][y]=='.') * { $ Panax Notoginseng if(a[x][y]=='.'&& count==1) - { theprintf"f (0,%c) =%d\n", a[x][y-1],number); + if(a[x][y+2]==' /') Aprintf"f (%d,%c) =1\n", number,a[x][y+1]); thenumber++; +Count=2; - } $ $ Else if(a[x][y]=='.'&& count!=1) - { - theprintf"f (%d,%c) =%d\n", number-1, a[x][y-1],number); - if(a[x][y+2]==' /')Wuyiprintf"f (%d,%c) =1\n", number,a[x][y+1]); thenumber++; - } Wu } - if(a[x][y]=='*') About { $ if(a[x][y]=='*'&& count==1) - { -printf"f (0,^) =%d\n", number); -printf"f (%d,%c) =%d\n", number,a[x][y-1],number); A if(a[x][y+1]==' /') +printf"f (%d,^) =1\n", number); the Else -printf"f (%d,^) =%d\n", number,number+1); $number++; theCount=2; the } the the Else if(a[x][y]=='*'&& count!=1) - { in theprintf"f (%d,%c) =%d\n", number,a[x][y-1],number); the if(a[x][y+1]==' /') Aboutprintf"f (%d,^) =1\n", number); the Else theprintf"f (%d,^) =%d\n", number,number+1); thenumber++; + } - } they++;Bayi } the } the -}
Conversion of a poor automaton