标签:sha class std i++ for getchar har blog tin
#include<stdio.h> #define MAX 20 main() { int i=0,j=0,k,l,m,n,number; char ch; char a[MAX][MAX]; printf("请输入正规式:"); ch=getchar(); while(ch!=‘\n‘) { if(ch==‘/‘) { a[i][j]=‘\0‘; j=0; i++; ch=getchar(); continue; } a[i][j]=ch; j++; ch=getchar(); } a[i][j]=‘\0‘; number=2; for(k=0;k<=i;k++) { l=0; m=1; while(a[k][l]!=‘\0‘) { if(a[k][l]==‘.‘||a[k][l]==‘*‘) { if(a[k][l]==‘.‘&&m==1) { m++; printf("f(0,%c)=%d\n",a[k][l-1],number); if(a[k][l+2]==‘\0‘) printf("f(%d,%c)=1\n",number,a[k][l+1]); number=number+1; } else if(a[k][l]==‘.‘&&m!=1) { m++; printf("f(%d,%c)=%d\n",number-1,a[k][l-1],number); if(a[k][l+2]==‘\0‘) printf("f(%d,%c)=1\n",number,a[k][l+1]); number=number+1; } else if(a[k][l]==‘*‘&&m==1) { m++; printf("f(0,~)=%d\n",number); printf("f(%d,%c)=%d\n",number,a[k][l-1],number); if(a[k][l+1]==‘\0‘) printf("f(%d,~)=1\n",number); else printf("f(%d,~)=%d\n",number,number+1); number=number+1; } else if(a[k][l]==‘*‘&&m!=1) { m++; printf("f(%d,%c)=%d\n",number,a[k][l-1],number); if(a[k][l+1]==‘\0‘) printf("f(%d,~)=1\n",number); else printf("f(%d,~)=%d\n",number,number+1); number=number+1; } } l++; } } }
标签:sha class std i++ for getchar har blog tin
原文地址:http://www.cnblogs.com/zzrf/p/6117316.html