2018-01-29 22:48:37 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
2018-03-12 23:53:49 +03:00
|
|
|
|
2018-01-29 22:48:37 +03:00
|
|
|
#ifndef WINDOWS
|
2018-03-12 23:53:49 +03:00
|
|
|
#ifndef KOS32
|
2018-01-29 22:48:37 +03:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2018-03-12 23:53:49 +03:00
|
|
|
#endif
|
2018-01-29 22:48:37 +03:00
|
|
|
|
|
|
|
void randomize(void) {
|
|
|
|
srand((int)time(NULL));
|
|
|
|
}
|
|
|
|
|
2018-03-12 23:53:49 +03:00
|
|
|
#if !defined(KOS32) && !defined(__TINYC__)
|
2018-01-29 22:48:37 +03:00
|
|
|
int max(int a, int b) {
|
|
|
|
if (a > b) return a;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
int min(int a, int b) {
|
|
|
|
if (a < b) return a;
|
|
|
|
return b;
|
|
|
|
}
|
2018-03-12 23:53:49 +03:00
|
|
|
#endif
|
|
|
|
|
2018-01-29 22:48:37 +03:00
|
|
|
#ifndef WINDOWS
|
2018-03-12 23:53:49 +03:00
|
|
|
#ifndef KOS32
|
2018-01-29 22:48:37 +03:00
|
|
|
int // <editor-fold defaultstate="collapsed" desc="comment">
|
|
|
|
getch// </editor-fold>
|
|
|
|
(void) {
|
|
|
|
char chbuf[1];
|
|
|
|
struct termios oldstate, newstate;
|
|
|
|
fflush(stdout);
|
|
|
|
tcgetattr(0, &oldstate);
|
|
|
|
newstate = oldstate;
|
|
|
|
newstate.c_lflag &= ~ICANON;
|
|
|
|
newstate.c_lflag &= ~ECHO;
|
|
|
|
tcsetattr(0, TCSANOW, &newstate);
|
|
|
|
read(0, &chbuf, 1);
|
|
|
|
tcsetattr(0, TCSANOW, &oldstate);
|
|
|
|
return chbuf[0];
|
|
|
|
}
|
2018-03-12 23:53:49 +03:00
|
|
|
#endif
|
2018-01-29 22:48:37 +03:00
|
|
|
#endif
|