Сабж.
#include <curses.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
int main()
{
int slx, sly, cx[4], cy[4], i, dflag;
char c2016[] = { '2', '0', '1', '6' };
srand(time(0));
initscr();
clear();
noecho();
curs_set(0);
cbreak();
slx = COLS / 2 - 2;
sly = LINES / 2;
for (i = 0; i < 4; i++) {
cx[i] = (int)((double)COLS * rand() / (RAND_MAX + 1.0));
cy[i] = (int)((double)LINES * rand() / (RAND_MAX + 1.0));
printf("%d, %d\n", cx[i], cy[i]);
}
for (;;) {
for (i = 0; i < 4; i++)
mvaddch(cy[i], cx[i], c2016[i]);
refresh();
sleep(1);
for (i = 0; i < 4; i++)
mvaddch(cy[i], cx[i], ' ');
dflag = 1;
for (i = 0; i < 4; i++) {
if (cx[i] < slx + i) {
cx[i]++;
dflag = 0;
}
if (cx[i] > slx + i) {
cx[i]--;
dflag = 0;
}
if (cy[i] < sly) {
cy[i]++;
dflag = 0;
}
if (cy[i] > sly) {
cy[i]--;
dflag = 0;
}
}
if (dflag)
break;
}
endwin();
return 0;
}