Esempio n. 1
0
void QuickSorter::qSort(int array[], int left, int right)
{
    if (left < right)
        {
            int correctPosition = putElement(array, left, right);
            qSort(array, left, correctPosition - 1);
            qSort(array, correctPosition + 1, right);
        }
}
Esempio n. 2
0
int main (int argc, char **argv)
{
	srand(time(0));

	MAP map;
	setDefaults(&map);

	PLAYER hero;
	startPlayer(&hero);

	getargs(&map, &hero, argc, argv);

	startMap(&map);
	hero.face = map.elements.hero.face;
	hero.pos = putElement(&map, hero.face);

	GHOSTS ghosts;
	ghosts.face = GHOST;
	ghosts.count = 0;

	startGhosts(&map, &ghosts);

	fflush(stdout);
	initscr();
	nodelay(stdscr, TRUE);
	noecho();
	keypad(stdscr, TRUE);

	if (map.props.hascolor)
		startColors();

	struct timespec tim, tim2;
	tim.tv_sec = 0;
	tim.tv_nsec = map.props.speed;

	do {
		nanosleep(&tim, &tim2);
		getCommand(&hero);
		walk(&map, &hero, &ghosts);
		showMap(&map, &hero, &ghosts);
		repopMap(&map);
		upGhosts(&map, &ghosts);
		walkGhosts(&map, &ghosts);

	} while (!isDead(&hero));

	if (!noRecords)
		writeRecords(&hero, &ghosts);
	finalize(&map, &ghosts);
	finalText(&map, &hero, &ghosts);

	exit(0);

}