Question

write a pseudocode to  Calculate the number of incorrect cells in matrix N*N in C++ //Calculate the...

write a pseudocode to  Calculate the number of incorrect cells in matrix N*N

in C++

//Calculate the number of incorrect cells
int gxCalc(int state[N][N])
{
}

//Node class
class Node
{
};

complete it please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int N=26; // N can be anything user's choice

int gxCalc(int state[][N])

{

int cnt=0;

for(int i=0;i<N;i++)

{

for(int j=0;j<N;j++)

{

if(state[i][j]==-1)// incorrect cell present

{

cnt++;

}

}

}

return cnt;

}

Pseudocode

intialise cnt=0

in the state 2d array

first start from row i=0 and increment til i=N-1;

for every row i

first start from column j=0 and increment til j=N-1;

if any state[i][j]==-1 increase the count by 1

after all the cells have been visited return the cnt value.

Add a comment
Know the answer?
Add Answer to:
write a pseudocode to  Calculate the number of incorrect cells in matrix N*N in C++ //Calculate the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT