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

📄 keyscan.cpp

📁 学生成绩管理系统。实现学生的添加 删除和各科成绩管理。
💻 CPP
字号:
#include <conio.h>
#include <ctype.h>
#include <stdarg.h>

#ifndef NULL
	#ifdef __cplusplus
		#define NULL 0
	#else
		#define NULL ((void *)0)
	#endif
#endif

int scankey(bool allowalpha, bool allowdigit, int* const extrakeys, int extracount)
{
	int ch,i;
	bool alpha, digit;
	while (1)
	{
		ch=getch();
		if (ch==0 || ch==224) ch=getch()+256;

		if (extrakeys!=NULL)
		{
			for (i=0; i<extracount; ++i)
			{
				if (ch==extrakeys[i]) return tolower(ch);
			}
		}

		alpha=isalpha(ch)!=0;
		if ( !allowalpha && alpha ) continue;
		digit=isdigit(ch)!=0;
		if ( !allowdigit && digit ) continue;

		if (!(alpha || digit)) continue;

		return tolower(ch);
	}
}

int scankey(bool allowalpha, bool allowdigit, int spe, ...)
{
	bool alpha, digit;
	int ch,i;
	va_list maker;
	while (1)
	{
		ch=getch();
		if (ch==0 || ch==224) ch=getch()+256;

		i=spe;
		va_start(maker,spe);
		while (i!=0)
		{
			if (ch==i)
			{
				va_end(maker);
				return tolower(ch);
			}
			i=va_arg(maker,int);
		}
		va_end(maker);

		alpha=isalpha(ch)!=0;
		if ( !allowalpha && alpha ) continue;
		digit=isdigit(ch)!=0;
		if ( !allowdigit && digit ) continue;

		if (!(alpha || digit)) continue;

		return tolower(ch);
	}
}

⌨️ 快捷键说明

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