⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2480980_ac_0ms_120k.cpp

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CPP
字号:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
	int t, i;
	char str[1001];

	scanf("%d",&t);
	while(t--)
	{
		scanf("%s",str);
		if(str[0]=='+'||str[0]=='-')
			strcpy(str,&str[1]);
		i = 0;
		while(str[i]!='\0'&&isdigit(str[i]))
			i++;
		if(i==0)
		{
			printf("ILLEGAL\n");
			continue;
		}
		if(str[i]=='\0')
		{
			printf("LEGAL\n");
			continue;
		}
		if(str[i]=='.')
		{
			strcpy(str,&str[i+1]);
			i = 0;
			while(str[i]!='\0'&&isdigit(str[i]))
				i++;
			if(i==0)
			{
				printf("ILLEGAL\n");
				continue;
			}
			if(str[i]=='\0')
			{
				printf("LEGAL\n");
				continue;
			}
			if(str[i]=='e'||str[i]=='E')
			{
				strcpy(str,&str[i+1]);
				goto E;
			}
			printf("ILLEGAL\n");
			continue;
		}
		if(str[i]=='e'||str[i]=='E')
		{
			strcpy(str,&str[i+1]);
E:
			if(str[0]=='+'||str[0]=='-')
				strcpy(str,&str[1]);
			i = 0;
			while(str[i]!='\0'&&isdigit(str[i]))
				i++;
			if(i==0)
			{
				printf("ILLEGAL\n");
				continue;
			}
			if(str[i]=='\0')
			{
				printf("LEGAL\n");
				continue;
			}
			printf("ILLEGAL\n");
			continue;
		}
		printf("ILLEGAL\n");
		continue;
	}
	return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -