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