?? cffx.c
字號:
/*電信系 計算機科學與技術專業 0412班 04117207 錢興*/
#include "stdio.h"
#include "string.h"
char str[100],v[100];
char ch1[100]="begin",ch2[100]="if",ch3[100]="then",ch4[100]="while",ch5[100]="do",ch6[100]="end";
int i=0,k,z=0,w,j,u,sgn;
main()
{puts("Please input code:");
gets(str);
k=strlen(str);
for (i=0;i<k;i++)
{if(str[i]==' ') continue;
if (((str[i]>=65)&&(str[i]<=90))||((str[i]>=97)&&(str[i]<=122)))
{ z=0;
do
{
v[z]=str[i];
z++;
i++;
switch (str[i])
{case ' ':w=0;break;
case '\0':w=0;break;
default:w=1;}
}while ((w!=0));
v[z]='\0';
for(j=0;j<strlen(v);j++)
{if (((v[j]>=65)&&(v[j]<=90))||((v[j]>=97)&&(v[j]<=122))||((v[j]>=48)&&(v[j]<=57)))
u=1;
else {u=0;break;}}
if (u==1)
{if (strcmp(v,ch1)==0){sgn=1;printf("(%d,%s)",sgn,v);}
else if (strcmp(v,ch2)==0){sgn=2;printf("(%d,%s) ",sgn,v);}
else if (strcmp(v,ch3)==0){sgn=3;printf("(%d,%s) ",sgn,v);}
else if (strcmp(v,ch4)==0){sgn=4;printf("(%d,%s) ",sgn,v);}
else if (strcmp(v,ch5)==0){sgn=5;printf("(%d,%s) ",sgn,v);}
else if (strcmp(v,ch6)==0){sgn=6;printf("(%d,%s) ",sgn,v);}
else {sgn=10;printf("(%d,%s)",sgn,v);}
}
else printf("(Error:%s) ",v);
}
else if ((str[i]>=48)&&(str[i]<=57))
{ z=0;
do
{
v[z]=str[i];
z++;
i++;
switch (str[i])
{case ' ':w=0;break;
case '\0':w=0;break;
default:w=1;}
}while ((w!=0));
v[z]='\0';
for(j=0;j<strlen(v);j++)
{if ((v[j]>=48)&&(v[j]<=57))
u=1;
else {u=0;break;}}
if (u==1)
{sgn=11;printf("(%d,%s) ",sgn,v);}
else printf("(Error:%s )",v);
}
else
if ((str[i]=='#')||(str[i]=='+')||(str[i]=='-')||(str[i]=='*')||(str[i]=='/')||(str[i]=='=')||(str[i]=='(')||(str[i]==')')||(str[i]=='<')||(str[i]=='>')||(str[i]==';')||(str[i]==':'))
{ z=0;
while ((str[i]!=' '))
{
v[z]=str[i];
z++;
i++;
}
v[z]='\0';
if (strcmp(v,"+")==0){sgn=13;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"-")==0){sgn=14;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"*")==0){sgn=15;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"/")==0){sgn=16;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,":")==0){sgn=17;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,";")==0){sgn=26;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"=")==0){sgn=25;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"<")==0){sgn=20;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,">")==0){sgn=23;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"(")==0){sgn=27;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,")")==0){sgn=28;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"<>")==0){sgn=21;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,">=")==0){sgn=24;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"#")==0){sgn=0;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,":=")==0){sgn=18;printf("(%d,%s) ",sgn,v);}
else if(strcmp(v,"<=")==0){sgn=22;printf("(%d,%s) ",sgn,v);}
else printf("(Error:%s)",v);
}
else {
{ z=0;
while (str[i]!=' ')
{
v[z]=str[i];
z++;
i++;
}
v[z]='\0';
}
printf ("(Error:%s)",v);}
i--;
}
getch();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -