不等待回车直接输入一个字符
仅在Linux下有效
#include <termio.h>
int getcharl() {
struct termios new_settings;
struct termios stored_settings;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
new_settings.c_lflag &= (~ICANON);
new_settings.c_cc[VTIME] = 0;
new_settings.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &new_settings);
int c = getchar();
tcsetattr(0, TCSANOW, &stored_settings);
return c;
}
输入不回显
仅在Linux下有效
#include <cstdlib>
system("stty -echo"); //输入不回显
system("stty echo"); // 输入回显
根据这个搞出来的迷惑操作
方向键控制
#include <cstdio>
#include <termio.h>
#include <cstdlib>
#include <queue>
#include <utility>
#include <ctime>
#define UP 65
#define LEFT 68
#define DOWN 66
#define RIGHT 67
using namespace std;
int getcharl() {
struct termios new_settings;
struct termios stored_settings;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
new_settings.c_lflag &= (~ICANON);
new_settings.c_cc[VTIME] = 0;
new_settings.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &new_settings);
int c = getchar();
tcsetattr(0, TCSANOW, &stored_settings);
return c;
}
void gt(int x, int y) {
printf("