#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
#define LEN 100
int nums[6];
void draw() {
for (int i=0; i<6; i++) {
if (nums[i] == 0)
continue;
int num = nums[i];
for (int j=0; j<=2*(num+1); j++) {
int t = min(j, 2*num + 2 -j);
t = max(0, t-1);
string str = string(t, ' ');
t = min(j, 2*num + 2 -j);
if (t == 0) {
str += "+" + string(2*num-1, '-') + "+";
} else if (t < num){
str += "|+" + string(2*num-1-2*t, '-') + "+|";
} else if (t == num){
str += "| |";
}
cout << str << endl;
}
}
}
int main(void) {
char str[LEN];
cin.getline(str, LEN);
int cnt = 0;
memset(nums, 0, sizeof(nums));
int j = 5;
for (int i=strlen(str) - 1; i>=0; i--) {
if (str[i] == ']') {
cnt ++;
} else {
nums[j] = cnt;
j--;
cnt = 0;
}
}
draw();
return 0;
}
提交的时候有个问题, 差两分钟没改完,只过了30%