1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class View
{
vector<string> showMap;
int ROWS, COLS;
public:
View( int r = 10, int c = 10 ) : ROWS( r ), COLS( c ){ showMap = vector<string>( r, string( c, ' ' ) ); }
void set( int i, int j, char c ){ if ( i >= 0 && i < ROWS && j >= 0 && j < COLS ) showMap[i][j] = c; }
void print(){ for ( auto &s : showMap ) cout << '|' << s << '|' << '\n'; }
};
int main()
{
View V( 4, 10 );
V.set( 0, 0, 'H' );
V.set( 1, 1, 'T' );
V.set( 3, 9, 'C' );
V.print();
}
|