![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
#include <iostream>
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
#include <
string>
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
#include <algorithm>
using namespace std;
int main()
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
{
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;
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
begIdx = line.find_first_of(tag);
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
numRow = atoi((line.substr(0,begIdx)).c_str());
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
begIdx = line.find_first_not_of(tag, begIdx);
while(begIdx < line.length() - 1)
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
{
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
endIdx = line.find_first_of(tag, begIdx);
if(endIdx ==
string::npos)
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
endIdx = line.length();
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
numCln = atoi((line.substr(begIdx,endIdx - begIdx)).c_str());
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
begIdx = line.find_first_not_of(tag, endIdx);
char val = line[begIdx];
for(
int j = clnIdx; j < clnIdx + numCln; j++){
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
cArry[j] = val;
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
clnIdx += numCln;
if(begIdx < line.length() - 1)
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
begIdx = line.find_first_not_of(tag, ++begIdx);
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}
for(
int i = rowIdx; i < rowIdx + numRow; i++){
for(
int j = 0; j < 9; j++)
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
cMatrix[i][j] = cArry[j];
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
rowIdx += numRow;
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}
for(
int i = 0; i < 12; i++){
for(
int j = 0; j < 9; j++){
if(cMatrix[i][j] == 'b')
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
cout <<
" " ;
else ![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
cout << cMatrix[i][j];
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
cout << endl;
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}
![编程珠玑3.7.6_职场](https://s2.51cto.com/images/editer/InBlock.gif)
}