Anonymní profil WolfWarrior – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil WolfWarrior – Programujte.comAnonymní profil WolfWarrior – Programujte.com

 

Příspěvky odeslané z IP adresy 217.73.24.–

WolfWarrior
C / C++ › 15 hlavolam v C++
26. 1. 2012   #152897

Nasiel som takyto kod ale teraz neviem co tam mam presne zadat nech tam napisem hocico program spadne

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define MAX_FILE_LENGTH 30
#define PUZZLE_SIDE 4
#define EMPTY_SLOT 0

void loadPuzzle(int puzzle[][PUZZLE_SIDE], FILE *fin);
int getMove();
void printPuzzle(int puzzle[][PUZZLE_SIDE]);
int doMove(int puzzle[][PUZZLE_SIDE], int move);
void swap(int *a, int *b);
int solved(int puzzle[][PUZZLE_SIDE]);

int main() {

int puzzle[PUZZLE_SIDE][PUZZLE_SIDE];
char filename[MAX_FILE_LENGTH+1];
int ans;

srand( 0 );

printf("Welcome to the PUZZLE-15 game!\n");


printf("Enter the file storing all of the puzzle configurations.\n");
scanf("%s", filename);

while (ans != 2) {

FILE *fin;
fin = fopen(filename, "r");


loadPuzzle(puzzle, fin);
fclose(fin);


int move;

printPuzzle(puzzle);
move = getMove();


while (move!=0) {


int okay = doMove(puzzle, move);


if (!okay) {
printf("Sorry, that is not a valid square to slide into ");
printf(" the open slot.\nNo move has been executed.\n");
}


else if (solved(puzzle))
break;


printPuzzle(puzzle);
move = getMove();
}


if (move != 0)
printf("Great, you solved the puzzle!!!\n");
else
printf("Sorry, looks like you gave up on the puzzle.\n");


printf("Which selection would you like?\n");
printf("1. Load a new puzzle.\n");
printf("2. Quit.\n");
scanf("%d", &ans);
}

}


void loadPuzzle(int puzzle[][PUZZLE_SIDE], FILE *fin) {

}


int getMove() {

}


void printPuzzle(int puzzle[][PUZZLE_SIDE]) {

}


int doMove(int puzzle[][PUZZLE_SIDE], int move) {

}


void swap(int *a, int *b) {

}


int solved(int puzzle[][PUZZLE_SIDE]) {

}

WolfWarrior
C / C++ › 15 hlavolam v C++
26. 1. 2012   #152896

Aha uz som to nasiel vazne vdaka dost mi to pomohlo

WolfWarrior
C / C++ › 15 hlavolam v C++
25. 1. 2012   #152869

Nazdar potreboval by som vediet ako mam spravit 15 hlavolam v C++ kedze neviem ani zacat

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý