10.9 write a function to transpose an integer matrix of 3*3 ., Integer 10.9
# Include <stdio. h> int main () {int arr [] [3] = {1, 2, 3}, {4, 5, 6}, {7, 8, 9 }}; printf ("before change! \ N "); int I, j, t; for (I = 0; I <3; I ++) {for (j = 0; j <3; j ++) {printf ("% 3d", * (arr + I) + j);} printf ("\ n ");} for (I = 0; I <3; I ++) {for (j = 0; j <I; j ++) {t = * (arr + I) + j); * (arr + I) + j) = * (arr + j) + I); * (arr + j) + I) = t;} // printf ("after change! \ N "); for (I = 0; I <3; I ++) {for (j = 0; j <3; j ++) {printf ("% 3d", * (arr + I) + j);} printf ("\ n");} return 0 ;}
Result:
I made a small mistake. I used printf ('\ n') to output the line feed, and changed it to double quotation marks. The usage of printf () is attached.
1. the printf () function is a formatting output function, which is generally used to output information to the standard output device in the specified format.
2. The call format of the printf () function is: printf ("<Format String>", <parameter table> ).
3. Format output: it is a function that generates format output in C Language (defined in stdio. h ). Used to output characters to terminals (monitors, consoles, etc.
Format control consists of text and data format description to be output. In addition to letters, numbers, spaces, and digit symbols,
You can also use escape characters to indicate special meanings.
4. Purpose: generate a formatted output function (defined in stdio. h) in the C language, which outputs characters to the terminal (display, console, etc.