if (nums[i][t] != 0 && nums[i][t] !=0)
{
numsquares++
}
Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!
This code is checking the exact same thing twice. That's not going to do you any good. I'm not sure what you are trying to do here. Perhaps you are trying to address the problem of remembering what squares you have already checked. This will require a second matrix of the same size as your input matrix (10 x 10). This matrix will hold bool values instead of int values, and should initially be full of false's.if (nums[i][t] != 0 && nums[i][t] !=0)
The kind of loop you need to use is determined by what you are trying to do. Here you need to loop through each element of the matrix and do something. That should sound familiar. It's just like when you read the matrix from the file. At that point you looped through each element of the matrix and did something else (read it from the file). So the loop you use now should be the same kind you used when you read the matrix in - to quote your own code:also what would I want my loop to be?? Another for loop or just an if statement or a do while??
The stuff you need to do here in this loop is much more complicated than just checking to see if the value is zero or not. (This is where you really need to talk to someone in person about what to do.) You need to write a seperate function to do it. You should pass to the function the matrix containing the int values, the matrix containing the bool values, and the current location of the loop (i and t). The function should return the size of the block at that location. If the function didn't find a block, it should return zero.for(i = 0; i < 3; i++) { for(t = 0; t < 3; t++) { // Do your stuff here (this is where you read the matrix in before) } }
0 members, 0 guests, 0 anonymous users
Community Forum Software by IP.Board
Licensed to: Geeks to Go, Inc.