# include # include using namespace std; int main ( ) // // MONA_FRAME reads data from a PGM graphics file of the Mona Lisa, // whites out two rows and two columns, and writes the data back out. // // The program should be run with commands like: // // g++ mona_frame.cpp // mv a.out mona_frame // ./mona_frame < mona.pgm > mona_frame.pgm // { char c1, c2; int cols, g_max, i, j, p_num, rows; int mona[360][250]; // // This part of the code reads some initial data from the graphics file. // cin >> c1; cin >> c2; cin >> cols; cin >> rows; cin >> g_max; // // Read the pixel data into the 2D array. // p_num = 0; for ( i = 0; i < rows; i++ ) { for ( j = 0; j < cols; j++ ) { cin >> mona[i][j]; p_num = p_num + 1; } } // // White out rows 30 and 120, columns 75 and 175. // We guess this will roughly frame the face. // for ( j = 0; j < cols; j++ ) { mona[30][j] = 255; mona[120][j] = 255; } for ( i = 0; i < rows; i++ ) { mona[i][75] = 255; mona[i][175] = 255; } // // Write the data back out. // First we have to write three lines of information about the data. // cout << c1 << c2 << "\n"; cout << cols << " " << rows << "\n"; cout << g_max << "\n"; for ( i = 0; i < rows; i++ ) { for ( j = 0; j < cols; j++ ) { cout << " " << mona[i][j]; } cout << "\n"; } return 0; }