#include <iostream>
using namespace std; class DoubleSubscriptArray { public : DoubleSubscriptArray ( int x, int y) { p = new int * [ x] ; for ( int i = 0 ; i < x; i++ ) { p[ i] = new int [ y] ; } for ( int i = 0 ; i < x; i++ ) for ( int j = 0 ; j < y; j++ ) p[ i] [ j] = 0 ; nx = x; ny = y; } int & operator ( ) ( int x, int y) { return p[ x] [ y] ; } const int & operator ( ) ( int x, int y) const { return p[ x] [ y] ; } bool operator == ( DoubleSubscriptArray & a) { if ( a. nx != nx || a. ny != ny) return false ; else { for ( int i = 0 ; i < a. nx; i++ ) for ( int j = 0 ; j < a. ny; j++ ) { if ( a. p[ i] [ j] != p[ i] [ j] ) return false ; } return true ; } } bool operator != ( DoubleSubscriptArray & a) { return ! ( a == * this ) ; } friend ostream & operator << ( ostream & os, const DoubleSubscriptArray & a) ; friend istream & operator >> ( istream & is, DoubleSubscriptArray & a) ; public : ~ DoubleSubscriptArray ( ) { for ( int i = 0 ; i < nx; i++ ) delete [ ] p[ i] ; delete [ ] p; } public : void print ( int x, int y) { for ( int i = 0 ; i < x; i++ ) for ( int j = 0 ; j < y; j++ ) { cout << p[ i] [ j] << endl; } } private : int * * p; int nx, ny; } ; ostream & operator << ( ostream & os, const DoubleSubscriptArray & a) { for ( int i = 0 ; i < a. nx; i++ ) { for ( int j = 0 ; j < a. ny; j++ ) os << a. p[ i] [ j] << " " ; os << endl; } return os;
} istream & operator >> ( istream & is, DoubleSubscriptArray & a) { for ( int i = 0 ; i < a. nx; i++ ) { for ( int j = 0 ; j < a. ny; j++ ) is >> a. p[ i] [ j] ; } return is;
} int main ( ) { DoubleSubscriptArray a ( 3 , 4 ) ; DoubleSubscriptArray c ( 3 , 4 ) ; DoubleSubscriptArray d ( 3 , 4 ) ; cin >> d; cout << d << endl; a ( 0 , 2 ) = 100 ; if ( a != c) cout << "yes" << endl; int b = a ( 0 , 2 ) ; cout << b << endl; a. print ( 3 , 4 ) ; cout << a << endl; return 0 ;
}