#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<math.h>
int main() {
int i = 0, j, k = 0, state = 1, f = 0, linenum = 1;
char a[11][10] = { “const”,“var”,“call”,“begin”,“if”,“while”,“do”,“odd”,“end”,“then”,“procedure” };
char b, d[40] = { “\0” };
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
b = getchar();
printf(“1为保留字,2为运算符,3为标示符,4为常数,5为分隔符\n”);
while (b != EOF)/* 判断所输入字符是否为结束符 */ {
if (b == ' ' || b == '\n' || b == '\t')/* 滤过空格、换行等分隔符号 */
{
if (b = '\n')
linenum++;
b = getchar();
}
else if ((b >= 'a'&&b <= 'z') || (b >= 'A'&&b <= 'Z'))/* 识别标识符以及保留字 */
{
d[i++] = b;
b = getchar();
while ((b >= 'a'&&b <= 'z') || (b >= 'A'&&b <= 'Z') || (b >= '0'&&b <= '9'))
{
d[i++] = b; b = getchar();
} for (j = 0; j < 11; j++)/* 查询保留字表确定该单词是否是保留字 */
{
if (strcmp(d, a[j]) == 0)
{