Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 10747

Game of Fifteen, one of the assignments in Problem Set 3

2 votes
Accepted

pset3 fifteen's draw function problem

I just tested your code and got it working with a couple minor tweaks. My advice is to go look back at your global variables. Something you have in both those functions has been declared earlier in or …
Peter's user avatar
  • 1,410
1 vote

Pset3 Fifteen: Can't use declared variable in the while loop

One other issue you'll have to deal with later is your use of swap in this line: swap(board[d-1][d-2], board[d-1][d-3]); When you pass those values into that function, you're passing copies of those …
Peter's user avatar
  • 1,410
1 vote
Accepted

Why isn't my board populating?

Remove this line of code from your init function: int board[d][d]; The global variable for the board is declared at the top of the code already (around line 30). You are supposed to use that, so you …
Peter's user avatar
  • 1,410
0 votes
Accepted

what does the fflush(file) do exactly?

If you have a working implementation of fifteen, run the program and watch log.txt as the game progresses. Each state of the board and each move are recorded "in real time" in the log file. Now, comme …
Peter's user avatar
  • 1,410