#include <iostream>
#include <iomanip>
int main( int argc, const char * argv[ ] ) {
int total_rows, total_cols;
std:: cout << "Please enter number of rows: " ;
std:: cin >> total_rows;
std:: cout << "Please enter number of columns: " ;
std:: cin >> total_cols;
int * matrix = new int [ total_rows* total_cols] ;
std:: cout << "Initialize matrix: \n " ;
for ( int row = 0 ; row < total_rows; row++ ) {
for ( int col = 0 ; col < total_cols; col++ ) {
std:: cin >> matrix[ col + row* total_rows] ;
}
}
std:: cout << "Matrix:\n " ;
for ( int row = 0 ; row < total_rows; row++ ) {
for ( int col = 0 ; col < total_cols; col++ ) {
std:: cout << std:: setw ( 3 ) << matrix[ col + row* total_rows] ;
}
std:: cout << "\n " ;
}
int row_number;
std:: cout << "\n Enter row number (zero-based) to calculate sum for: " ;
std:: cin >> row_number;
int sum = 0 ;
for ( int col = 0 ; col < total_cols; col++ ) {
sum + = matrix[ col + row_number* total_cols] ;
}
std:: cout << "Sum = " << sum << "\n " ;
delete [ ] matrix;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KCmludCBtYWluKGludCBhcmdjLCBjb25zdCBjaGFyKiBhcmd2W10pIHsKICAgIGludCB0b3RhbF9yb3dzLCB0b3RhbF9jb2xzOwoKICAgIHN0ZDo6Y291dCA8PCAiUGxlYXNlIGVudGVyIG51bWJlciBvZiByb3dzOiAiOwogICAgc3RkOjpjaW4gPj4gdG90YWxfcm93czsKCiAgICBzdGQ6OmNvdXQgPDwgIlBsZWFzZSBlbnRlciBudW1iZXIgb2YgY29sdW1uczogIjsKICAgIHN0ZDo6Y2luID4+IHRvdGFsX2NvbHM7CgogICAgaW50KiBtYXRyaXggPSBuZXcgaW50W3RvdGFsX3Jvd3MqdG90YWxfY29sc107CgogICAgc3RkOjpjb3V0IDw8ICJJbml0aWFsaXplIG1hdHJpeDogXG4iOwoKICAgIGZvciAoaW50IHJvdyA9IDA7IHJvdyA8IHRvdGFsX3Jvd3M7IHJvdysrKSB7CiAgICAg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