zoukankan      html  css  js  c++  java
  • 词法转换

    #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);
    }
  • 相关阅读:
    Linux(实操篇)--- 实用指令-运行级别和找回root密码
    Python使用文件操作实现一个XX信息管理系统的示例
    python解释器安装教程的方法步骤
    python如何使用代码运行助手
    python 识别登录验证码图片功能的实现代码(完整代码)
    python线性插值解析
    python协程 详解
    maxcompute mapjoin
    spark split节点笔记
    安装和配置hadoop
  • 原文地址:https://www.cnblogs.com/Lorz/p/5924735.html
Copyright © 2011-2022 走看看