一个很神奇的画图形;
和不超过1000,所以可以用1000 * 1000 的数组来存; 找到最左边的位置开始, 往右赋值 ;
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1005;
int a[maxn];
char s[maxn][maxn];
int main(){
int n, sum = 0, sp = 0, ma=-1, ia = INF;
scanf("%d", &n);
for(int i=0;i<maxn;i++){
for(int j=0;j<maxn;j++){
s[i][j] = ' ';
}
}
for(int i=0;i<n;i++){
scanf("%d", &a[i]);
sp += a[i];
if(i % 2 == 0) sum += a[i];
else sum -= a[i];
ma = max(sum, ma);
ia = min(sum, ia);
// printf("%d %d %d %d\n", a[i], ma, ia, sum);
}
int cx = ma-1, cy=0;
for(int i=0;i<n;i++){
int cn = a[i];
char c = (i%2==0)?'/':'\\';
int dd = i%2==0?-1:1;
while(cn--){
s[cx][cy] = c;
if(cn>0) cx += dd;
cy++;
}
}
int la = ia<0?ma-ia:ma;
for(int i=0;i<la;i++){
for(int j=0;j<sp;j++){
printf("%c", s[i][j]);
}
puts("");
}
return 0;
}