解题思路:
注意事项:
参考代码:
#include <iostream> using namespace std; void transpose ( int a[][3] ) { for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 3; j++ ) if ( i < j ) { a[i][j] += a[j][i]; a[j][i] = a[i][j] - a[j][i]; a[i][j] -= a[j][i]; } return ; } int main() { int a[3][3] ={0}; for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 3; j++ ) cin >> a[i][j]; transpose( a ); for ( int i = 0; i < 3; i++ ) { for ( int j = 0; j < 3; j++ ) cout << a[i][j] << ' '; cout << endl; } cout << endl; return 0; }
0.0分
0 人评分