c puzzle

Cancelado Postado Oct 21, 2008 Pago na entrega
Cancelado Pago na entrega

Common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank.

The goal is to get the tiles in order, 1 through 15, from left to right, top to bottom, by just sliding tiles into the empty square. In this configuration, the goal would be to get the 14 and 15 to switch places, without affecting any of the other squares.

Your goal will be to write a program that allows the user to play this game.

The first part of your program will read in possible puzzle configurations from a file and choose one of them randomly. The file format is as follows:

The first line of the input file will contain a single positive integer n, representing the number of puzzles in the file. The puzzles will be contained in the next 5n lines. In particular, each puzzle will be stored in 5 lines. The first line will contain the first row of values in the puzzle separated by spaces. The second line will contain the second row, the third line, the third row and the fourth line, the fourth row. The blank spot will be designated by the integer 0. The last line (fifth) will be a blank line.

3

1 0 2 3

5 6 7 4

9 10 11 8

13 14 15 12

15 1 2 3

14 13 12 11

10 9 8 7

6 0 5 4

Output Specification

At the very beginning of the program, you will prompt the user to enter in the name of the file (this has already been done for you). Then, the program will open the file and load a puzzle into its memory. (You will do this in the loadPuzzle function.)

Once this is done, the puzzle should be displayed to the user (printPuzzle will do the work, but the call to this function is already in main) and the user should choose a tile to move. Roughly the board should print out as follows:

1 2 _ 3

5 6 7 4

9 10 11 8

13 14 15 12

Note that an underscore is to be used to denote the blank square and that internally, this is stored as 0.

Prompt the user with the following question after showing them the board:

Which piece would you like to slide into the open slot?

Note, answering 0 means you quit the game without winning.

If the user chooses a valid square, process the move and print out:

Sorry, that is not a valid square to slide into the open slot. No move has been executed.

If the user chooses 0, print out:

Sorry, looks like you gave up on the puzzle.

Engenharia MySQL PHP Gestão de projetos Arquitetura de software Teste de Software

ID do Projeto: #3326899

Sobre o projeto

20 propostas Projeto remoto Ativo em Oct 23, 2008

20 freelancers estão ofertando em média $41 nesse trabalho

marchent

See private message.

$85 USD in 14 dias
(168 Comentários)
6.3
bitdonkey

See private message.

$169.15 USD in 14 dias
(111 Comentários)
6.1
genergabasa

See private message.

$85 USD in 14 dias
(35 Comentários)
5.9
magadhmindslx

See private message.

$29.75 USD in 14 dias
(161 Comentários)
5.4
Apogeesolutions

See private message.

$42.5 USD in 14 dias
(68 Comentários)
4.5
vw6959454vw

See private message.

$21.25 USD in 14 dias
(48 Comentários)
4.4
dimic

See private message.

$34 USD in 14 dias
(14 Comentários)
4.4
alecn2002

See private message.

$102 USD in 14 dias
(20 Comentários)
4.3
drboom

See private message.

$16.15 USD in 14 dias
(27 Comentários)
4.2
winexsoft

See private message.

$12.75 USD in 14 dias
(19 Comentários)
4.0
pgmexpert

See private message.

$3.4 USD in 14 dias
(5 Comentários)
2.6
vw6807901vw

See private message.

$17 USD in 14 dias
(2 Comentários)
2.2
vw7056055vw

See private message.

$8.5 USD in 14 dias
(3 Comentários)
0.0
starscout

See private message.

$17 USD in 14 dias
(0 Comentários)
0.0
aselaben

See private message.

$27.2 USD in 14 dias
(0 Comentários)
0.0
levgvw

See private message.

$25.5 USD in 14 dias
(0 Comentários)
0.0
codeguru2008

See private message.

$42.5 USD in 14 dias
(1 Comentário)
0.0
wickedtoad

See private message.

$42.5 USD in 14 dias
(0 Comentários)
0.0
jimmysprogram

See private message.

$4.25 USD in 14 dias
(0 Comentários)
0.0
tbteam

See private message.

$25.5 USD in 14 dias
(0 Comentários)
0.0