识别浮点常量问题
来源:互联网 发布:软件开发公司上市资质 编辑:程序博客网 时间:2024/06/05 19:09
#点击阅读原题#
#include <iostream>#include <cstdio>#include <cstring>#include <string>using namespace std;int getnext(int x,char c) //依上图判断各种情况{ switch(x) { case 1: if(isdigit(c)) return 2; if(c=='-'||c=='+') return 3; return -1; case 2: if(isdigit(c)) return 2; if(c=='.') return 4; if(c=='e'||c=='E') return 5; return -1; case 3: if(isdigit(c)) return 2; return -1; case 4: if(isdigit(c)) return 6; return -1; case 5: if(isdigit(c)) return 7; if(c=='-'||c=='+') return 8; return -1; case 6: if(c=='e'||c=='E') return 5; if(c=='\0') return 0; if(isdigit(c)) return 6; return -1; case 7: if(c=='\0') return 0; if(isdigit(c)) return 7; return -1; case 8: if(isdigit(c)) return 7; return -1; }}int main(){ string s; getline(cin,s); //去除字符串两边的空格 s.erase(0,s.find_first_not_of(" ")); s.erase(s.find_last_not_of(" ")+1); int state=1; for(int i=0;i<=s.length();i++){ //要判断终结符 state=getnext(state,s[i]); if(state==-1) break; } printf("%s\n",state==0?"YES":"NO"); return 0;}
阅读全文
0 0
- 识别浮点常量问题
- 识别浮点常量问题
- 识别浮点常量问题
- 识别浮点常量问题
- 识别浮点常量问题
- 编译课程实验-识别浮点常量问题
- 识别浮点常量问题-编译原理程序实现
- 编译课程实验-识别浮点常量问题 SDUT
- 山东理工大学ACM平台题答案关于C语言 2098 识别浮点常量问题
- 字符串处理函数:识别一字符串所属的数值常量类型(十六进制、二进制、十进制整数,浮点数)
- 字符串处理函数:识别一字符串所属的数值常量类型(十六进制、二进制、十进制整数,浮点数)
- 常量问题
- 2.13.3 - [lex.fcon] - 【词法.浮点常量】
- C# 浮点数和货币值常量
- kettle 不识别自定义常量
- 浮点数取整等问题
- 浮点数误差问题?
- 浮点数问题
- CentOS7下引导Win7修改Win7为默认引导方法
- 201710042130->事件派发eventdispatch
- netty学习demo01
- 【整体二分+树状数组】BZOJ2527 [Poi2011]Meteors
- 【《WPF手册》读书笔记系列】第0章-C++&C#和MFC&WPF
- 识别浮点常量问题
- 猪八戒编程题2018_拼接N个整数成一个最大的多位整数
- 未来,命运,她
- 029 高阶导数之sinx(n)、cosx(n)及Leibniz公式
- 【《WPF手册》读书笔记系列】第一章-应用程序与窗口
- JSP代码练习(五)
- 背包九讲以及领悟
- Linux Kernel Compilation
- vue中键盘事件的处理