Home > Back-end >  Have a great god will?
Have a great god will?

Time:06-08

Enter a define a line 5 five columns of two-dimensional arrays, the 2 d array of the corresponding matrix elements of the two diagonals are assigned as the "+" characters, the rest of the element value assignment to characters "-", and will be the final result of neat output to the screen

CodePudding user response:

Through two-dimensional arrays, the coordinates of the on the diagonal (0.0) (1, 1) (2, 2) (3, 3) (4, 4), the rest is not on the diagonal values, so +, not -- -

CodePudding user response:

Direct output:
Printf (" + - + ");
Printf (" - + - + - ");
Printf (" - + - ");
Printf (" - + - + - ");
Printf (" + - + ");

: -)

To write algorithms are on the diagonal element subscript characteristics as follows: coordinates are equal, or 4
For (int I=0; i<5; I++) {
For (int j=0; J<5; J++)
If ((I + j==4) | | (I==j)) printf (" + "); The else printf (" - ");
printf("\n");
}

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related