#include <iostream>
using namespace std;
int main( ) {
int matrix1[ 3 ] [ 3 ] , matrix2[ 3 ] [ 3 ] , result[ 3 ] [ 3 ] ;
cout << "Enter elements of first 3x3 matrix:\n " ;
for ( int i = 0 ; i < 3 ; i++ ) {
for ( int j = 0 ; j < 3 ; j++ ) {
cin >> matrix1[ i] [ j] ;
}
}
cout << "Enter elements of second 3x3 matrix:\n " ;
for ( int i = 0 ; i < 3 ; i++ ) {
for ( int j = 0 ; j < 3 ; j++ ) {
cin >> matrix2[ i] [ j] ;
}
}
// Adding matrices
for ( int i = 0 ; i < 3 ; i++ ) {
for ( int j = 0 ; j < 3 ; j++ ) {
result[ i] [ j] = matrix1[ i] [ j] + matrix2[ i] [ j] ;
}
}
cout << "Resultant matrix after addition:\n " ;
for ( int i = 0 ; i < 3 ; i++ ) {
for ( int j = 0 ; j < 3 ; j++ ) {
cout << result[ i] [ j] << " " ;
}
cout << endl;
}
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbWF0cml4MVszXVszXSwgbWF0cml4MlszXVszXSwgcmVzdWx0WzNdWzNdOwoKICAgIGNvdXQgPDwgIkVudGVyIGVsZW1lbnRzIG9mIGZpcnN0IDN4MyBtYXRyaXg6XG4iOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAzOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDM7IGorKykgewogICAgICAgICAgICBjaW4gPj4gbWF0cml4MVtpXVtqXTsKICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCAiRW50ZXIgZWxlbWVudHMgb2Ygc2Vjb25kIDN4MyBtYXRyaXg6XG4iOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAzOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDM7IGorKykgewogICAgICAgICAgICBjaW4gPj4gbWF0cml4MltpXVtqXTsKICAgICAgICB9CiAgICB9CgogICAgLy8gQWRkaW5nIG1hdHJpY2VzCiAgICBmb3IgKGludCBpID0gMDsgaSA8IDM7IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgMzsgaisrKSB7CiAgICAgICAgICAgIHJlc3VsdFtpXVtqXSA9IG1hdHJpeDFbaV1bal0gKyBtYXRyaXgyW2ldW2pdOwogICAgICAgIH0KICAgIH0KCiAgICBjb3V0IDw8ICJSZXN1bHRhbnQgbWF0cml4IGFmdGVyIGFkZGl0aW9uOlxuIjsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgMzsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCAzOyBqKyspIHsKICAgICAgICAgICAgY291dCA8PCByZXN1bHRbaV1bal0gPDwgIiAiOwogICAgICAgIH0KICAgICAgICBjb3V0IDw8IGVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==