标签:int printf div getc png alt while else 结束
#include<stdio.h> main() { int i=0,j=0,x=0,y; int number=2; int count=0; char ch; char a[100][100]; printf("请输入正规式以#结束 :\n"); printf("^代表空\n"); printf("|代表或\n"); ch=getchar(); do { if(ch==‘|‘) { a[i][j]=‘\0‘; j=0; i++; ch=getchar(); continue; } a[i][j]=ch; j++; ch=getchar(); }while(ch!=‘#‘); a[i][j]=‘\0‘; for(x=0;x<=i;x++) { y=0; count=1; while(a[x][y]!=‘\0‘) { if(a[x][y]==‘.‘) { if(a[x][y]==‘.‘&& count==1) { printf("f(0,%c)=%d\n",a[x][y-1],number); if(a[x][y+2]==‘\0‘) printf("f(%d,%c)=1\n",number,a[x][y+1]); number++; count=2; } else if(a[x][y]==‘.‘&& count!=1) { printf("f(%d,%c)=%d\n",number-1,a[x][y-1],number); if(a[x][y+2]==‘\0‘) printf("f(%d,%c)=1\n",number,a[x][y+1]); number++; } } if(a[x][y]==‘*‘) { if(a[x][y]==‘*‘&& count==1) { printf("f(0,^)=%d\n",number); printf("f(%d,%c)=%d\n",number,a[x][y-1],number); if(a[x][y+1]==‘\0‘) printf("f(%d,^)=1\n",number); else printf("f(%d,^)=%d\n",number,number+1); number++; count=2; } else if(a[x][y]==‘*‘&& count!=1) { printf("f(%d,%c)=%d\n",number,a[x][y-1],number); if(a[x][y+1]==‘\0‘) printf("f(%d,^)=1\n",number); else printf("f(%d,^)=%d\n",number,number+1); number++; } } y++; } } }
标签:int printf div getc png alt while else 结束
原文地址:http://www.cnblogs.com/224yang/p/6182319.html