Q445: Marvelous Mazes

//Q445 Marvelous Mazes
//Accepted 2008-04-20 11:51:13

#include <iostream>
#include <string>

using namespace std;

int main(void)
{
int repeat = 0;
string data;

while(getline(cin, data))
{
for(int i = 0; i < data.length(); i++)
{
if (data[i] >= '0' && data[i] <= '9')
{
repeat += data[i] - 48;
continue;
}

if (data[i] == 'b')
{
for(int j = 0; j < repeat; j++)
cout << " ";
repeat = 0;
}

if (data[i] == '!')
cout << "\n";
else
{
for(int j = 0; j < repeat; j++)
cout << data[i];
repeat = 0;
}
}
cout << endl;
}
}

留言

這個網誌中的熱門文章

[教學] 在GMail 收台大Web Mail信件