#include<stdio.h> #define MAX 50 main() { char shuru[MAX]; do { printf("请输入想要识别的字符:(输入tuichu代表退出)\n"); scanf("%s",&shuru); if(strcmp(shuru,"begin") == 0) printf("符号为:%s,种别码为:1\n",shuru); else if(strcmp(shuru,"if") == 0) printf("符号为:%s,种别码为:2\n",shuru); else if(strcmp(shuru,"then") == 0) printf("符号为:%s,种别码为:3\n",shuru); else if(strcmp(shuru,"while") == 0) printf("符号为:%s,种别码为:4\n",shuru); else if(strcmp(shuru,"do") == 0) printf("符号为:%s,种别码为:5\n",shuru); else if(strcmp(shuru,"end") == 0) printf("符号为:%s,种别码为:6\n",shuru); else if(strcmp(shuru,"l(l|d)*") == 0) printf("符号为:%s,种别码为:10\n",shuru); else if(strcmp(shuru,"dd*") == 0) printf("符号为:%s,种别码为:11\n",shuru); else if(strcmp(shuru,"+") == 0) printf("符号为:%s,种别码为:13\n",shuru); else if(strcmp(shuru,"-") == 0) printf("符号为:%s,种别码为:14\n",shuru); else if(strcmp(shuru,"*") == 0) printf("符号为:%s,种别码为:15\n",shuru); else if(strcmp(shuru,"/") == 0) printf("符号为:%s,种别码为:16\n",shuru); else if(strcmp(shuru,":") == 0) printf("符号为:%s,种别码为:17\n",shuru); else if(strcmp(shuru,":=") == 0) printf("符号为:%s,种别码为:18\n",shuru); else if(strcmp(shuru,"<") == 0) printf("符号为:%s,种别码为:20\n",shuru); else if(strcmp(shuru,"<=") == 0) printf("符号为:%s,种别码为:21\n",shuru); else if(strcmp(shuru,"<>") == 0) printf("符号为:%s,种别码为:22\n",shuru); else if(strcmp(shuru,">") == 0) printf("符号为:%s,种别码为:23\n",shuru); else if(strcmp(shuru,">=") == 0) printf("符号为:%s,种别码为:24\n",shuru); else if(strcmp(shuru,"=") == 0) printf("符号为:%s,种别码为:25\n",shuru); else if(strcmp(shuru,";") == 0) printf("符号为:%s,种别码为:26\n",shuru); else if(strcmp(shuru,"(") == 0) printf("符号为:%s,种别码为:27\n",shuru); else if(strcmp(shuru,")") == 0) printf("符号为:%s,种别码为:28\n",shuru); else if(strcmp(shuru,"#") == 0) printf("符号为:%s,种别码为:0\n",shuru); else if(strcmp(shuru,"tuichu") == 0) { printf("退出成功!\n"); break; } else printf("无法识别此字符串!\n"); }while(-1); }