Update roofus.c

This commit is contained in:
Racoonicorn 2016-12-19 14:02:06 +01:00 committed by GitHub
parent 5f2820b6e2
commit a1ac74174f
1 changed files with 101 additions and 96 deletions

View File

@ -1,4 +1,4 @@
#define VERSION "0.01"
#define VERSION "0.02"
#define N 5
#include <stdio.h>
@ -26,6 +26,7 @@ int main () {
start ();
printm ();
while (end == 0) {
printf ("\nLeft: a. Up: w. Right: d. Down: s. Exit: 0");
printf ("\nDirection? ");
scanf ("%s", dir);
getchar ();
@ -65,6 +66,7 @@ void move(char * dir){
xinit = my_x;
yinit = my_y;
// move pointer
switch (dir[0]) {
case 'a':
if (my_x != 0) {
@ -102,7 +104,7 @@ void move(char * dir){
break;
}
if (stop == 0) {
// change values
if (*dir == 'd') {
for (j = 1 + xinit; j <= 4; j++) {
if (matrix[yinit][j] != 0) {
@ -144,16 +146,18 @@ void move(char * dir){
}
}
// if 1 or 2 -> random number
void nolow () {
int i, j;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if ( matrix[i][j] < 3 && matrix[i][j] > 0)
matrix[i][j] = (rand()%10)-10;
matrix[i][j] = rand () % 10 - 10;
}
}
}
// print matrix
void printm () {
int i, j;
printf ("\n\n");
@ -170,7 +174,7 @@ void printm(){
}
}
int win(){
int win () { // 20+ zeros
int i, j, count=0;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
@ -182,6 +186,7 @@ int win(){
printf ("\nYou win! Moves: %d", moves);
return 1;
}else{
printf ("\nYou still need to delete %d numbers", N * (N-1) - count);
return 0;
}
}