#include <stdio.h>
#include <ctype.h>
#include <string.h>
char *nexttoken();
char nextchar();
void next();
void back();
char *gettoken();
char cbuf[]="12.3*********klj12.2e2jj778";
int forward=-1;
int main(){
while(1){
printf("%s\n",nexttoken());
if (forward >=strlen(cbuf)-1){
getchar();
return 0;
}
}
}
int state;
int start;
char *nexttoken(){
char c;
state =12;
while(1){
switch(state){
case 12:
c=nextchar();
start=forward;
if(isdigit(c)){
state=13;
}else {
next();
}
break;
case 13:
c=nextchar();
if(isdigit(c))
state=13;
else if(c=='e'||c=='E')
state=16;
else if(c=='.')
state=14;
else
state=19;
break;
case 14:
c=nextchar();
if(isdigit(c))
state=15;
break;
case 15:
c=nextchar();
if(isdigit(c))
state=15;
else if(c=='e'||c=='E')
state=16;
else
state=19;
break;
case 16:
c=nextchar();
if(isdigit(c))
state=18;
else if(c=='+'||c=='-')
state=17;
break;
case 17:
c=nextchar();
if(isdigit(c))
state=18;
break;
case 18:
c=nextchar();
if(isdigit(c))
state=18;
else
state=19;
break;
case 19:
back();
return gettoken();
}
}
}
char nextchar(){
forward++;
return cbuf[forward];
}
void back(){
forward--;
}
void next(){
forward++;
}
char token_buf[128];
char *gettoken(){
int i,j=0;
for(i=start;i<=forward;i++){
token_buf[j++]=cbuf[i];
}
token_buf[j]='\0';
return token_buf;
}
Cifafenxi.rar_cifa
版权申诉
89 浏览量
2022-09-21
03:50:45
上传
评论
收藏 631B RAR 举报
御道御小黑
- 粉丝: 62
- 资源: 1万+
最新资源
- 数据库管理工具:dbeaver-ce-23.2.4-macos-aarch64.dmg
- 一个能够使用的幻兽帕鲁修改器
- java期末大作业课程设计学生成绩管理系统源码+数据库(高分项目)
- 数据库管理工具:dbeaver-ce-23.2.2-stable.x86-64.rpm
- 数据库管理工具:dbeaver-ce-23.2.2-macos-x86-64.dmg
- 数据库管理工具:dbeaver-ce-23.2.2-macos-aarch64.dmg
- 数据库管理工具:dbeaver-ce-23.1.5-stable.x86-64.rpm
- 以下是一些适用于英语六级作文的万能句型模板,涵盖了引言、正文和结论部分的各类表达方式.docx
- MATLAB中的非线性规划
- 进行C语言面试资格确认是招聘过程中一个重要的步骤,目的是确保候选人具备足够的C语言编程能力和知识.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈