版本比较
linux.h
正文
增加 33 行删除 33 行
123123456789109101112131415161717181920212122232425262727282930315 行未改动3738394041414243444546474848495050515253545556575859606162636465666768697071725253545556575859606162636465666768697071727374757652 行未改动129130131132133133134135136看到灌水区里一片windows小游戏,然而像我这种用linux的蒟蒻(嗯?)根本玩不了 ** so , 就有了这个头文件: ** 把windows.h和conio.h什么的换成下面这个就行了 看到灌水区里一片windows小游戏,然而像我这种用linux的蒟蒻(嗯?)根本玩不了** so , 就有了这个头文件: **把windows.h和conio.h什么的换成下面这个就行了
``` cpp#include <bits/stdc++.h>#include <sys/time.h>#include <termios.h> #include <unistd.h> #include <termios.h>#include <unistd.h>#include <fcntl.h>#include <sys/ioctl.h>int getch(){ struct termios tm, tm_old; int fd = 0, ch;
if (tcgetattr(fd, &tm) < 0) {//保存现在的终端设置 return -1; }
tm_old = tm; cfmakeraw(&tm);//更改终端设置为原始模式,该模式下所有的输入数据以字节为单位被处理 if (tcsetattr(fd, TCSANOW, &tm) < 0) {//设置上更改之后的设置 return -1; }
ch = getchar(); if (tcsetattr(fd, TCSANOW, &tm_old) < 0) {//更改设置为最初的样子 return -1; }5 行未改动 struct timezone tz; gettimeofday(&tv,&tz); return tv.tv_sec*1000 + tv.tv_usec/1000;}void gotonow(int x,int y)//X表示行,Y表示列 void gotonow(int x,int y)//X表示行,Y表示列{ if(x>0) printf("\033[%dB",x); else if(x<0) printf("\033[%dA",-x); if(y>0) printf("\033[%dC",y); else if(y<0) printf("\033[%dD",-y);}void gotoxy(int x,int y)//X表示行,Y表示列 void gotoxy(int x,int y)//X表示行,Y表示列{
}int kbhit(void) { struct termios oldt, newt; int ch; int oldf; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); oldf = fcntl(STDIN_FILENO, F_GETFL, 0); fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt); fcntl(STDIN_FILENO, F_SETFL, oldf); if(ch != EOF) { ungetc(ch, stdin); return 1; } return 0; } int kbhit(void){ struct termios oldt, newt; int ch; int oldf; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); oldf = fcntl(STDIN_FILENO, F_GETFL, 0); fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt); fcntl(STDIN_FILENO, F_SETFL, oldf); if(ch != EOF) { ungetc(ch, stdin); return 1; } return 0;}int system__(const char *s){ std::string ifs = s; if(ifs=="cls") return system("clear");52 行未改动 if(y == 1) return system__(("zenity --info --title=\"" + title + "\" --text=\"" + text + empty_line + "\" 2> /dev/null").c_str()); if(y == 2) return system__(("zenity --question --title=\"" + title + "\" --text=\"" + text + empty_line + "\" 2> /dev/null").c_str()); return -1; return -1;}#define clock clock__```