x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
3 9 x
6 3 b 3 x 3 b
3 9 x
9 3 x 6 b
3 9 x
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string line;
const string tag(" ");
int numRow = 0;
int rowIdx = 0;
char cMatrix[12][9];
char cArry[9];
while(getline(cin, line)){
int numCln = 0;
int clnIdx = 0;
string::size_type begIdx, endIdx;
begIdx = line.find_first_of(tag);
numRow = atoi((line.substr(0,begIdx)).c_str());
begIdx = line.find_first_not_of(tag, begIdx);
while(begIdx < line.length() - 1)
{
endIdx = line.find_first_of(tag, begIdx);
if(endIdx == string::npos)
endIdx = line.length();
numCln = atoi((line.substr(begIdx,endIdx - begIdx)).c_str());
begIdx = line.find_first_not_of(tag, endIdx);
char val = line[begIdx];
for(int j = clnIdx; j < clnIdx + numCln; j++){
cArry[j] = val;
}
clnIdx += numCln;
if(begIdx < line.length() - 1)
begIdx = line.find_first_not_of(tag, ++begIdx);
}
for(int i = rowIdx; i < rowIdx + numRow; i++){
for(int j = 0; j < 9; j++)
cMatrix[i][j] = cArry[j];
}
rowIdx += numRow;
}
for(int i = 0; i < 12; i++){
for(int j = 0; j < 9; j++){
if(cMatrix[i][j] == 'b')
cout << " " ;
else
cout << cMatrix[i][j];
}
cout << endl;
}
}