#pragma once
#include <iostream>
#include <vector>
#include <windows.h>
#include <iomanip>
using namespace std;
void AutoInput ( int ** data, int N, int M) {
for ( int i = 0 ; i < M; i++ )
for ( int j = 0 ; j < N; j++ ) {
data[ i] [ j] = rand ( ) % 50 ;
}
}
void Input ( int ** data, int N, int M) {
for ( int i = 0 ; i < M; i++ )
for ( int j = 0 ; j < N; j++ ) {
cin >> data[ i] [ j] ;
}
}
void OutPut( int ** data, int N, int M) {
for ( int i = 0 ; i < M; i++ ) {
for ( int j = 0 ; j < N; j++ ) {
cout << setw( 2 ) << data[ i] [ j] << " " ;
}
cout << endl;
}
}
void OutPutCopy( int ** data, int N, int M) {
for ( int i = 0 ; i < N; i++ ) {
for ( int j = 0 ; j < M; j++ ) {
cout << setw( 2 ) << data[ i] [ j] << " " ;
}
cout << endl;
}
}
void Transpose( int ** copy, int ** data, int N, int M) {
for ( int i = 0 ; i < M; i++ )
for ( int j = 0 ; j < N; j++ )
copy[ j] [ i] = data[ i] [ j] ;
}
I3ByYWdtYSBvbmNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHdpbmRvd3MuaD4KI2luY2x1ZGUgPGlvbWFuaXA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIEF1dG9JbnB1dCAoaW50ICoqIGRhdGEsIGludCBOLCBpbnQgTSkgewoJCglmb3IgKGludCBpID0gMDsgaSA8IE07IGkrKykKCQlmb3IgKGludCBqID0gMDsgaiA8IE47IGorKykgewoJCQlkYXRhW2ldW2pdID0gcmFuZCgpICUgNTA7CgkJfQoJCQp9Cgp2b2lkIElucHV0IChpbnQgKiogZGF0YSwgaW50IE4sIGludCBNKSB7CgkKCWZvciAoaW50IGkgPSAwOyBpIDwgTTsgaSsrKQoJCWZvciAoaW50IGogPSAwOyBqIDwgTjsgaisrKSB7CgkJCWNpbiA+PiBkYXRhW2ldW2pdOwoJfQoJCX0KCgp2b2lkIE91dF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