题目
#include <bits/stdc++.h>
using namespace std;
int n;
int w[110][110];
int a[110][110];
int main()
{
cin >> n;
int maxx = 0;
for (int i = 0; i < n; ++i)
{
int temp;
cin >> temp;
if (maxx < temp)
maxx = temp;
//标记需要更新的值
for (int j = 0; j < temp * 10; ++j)
{
w[i][j] = 1;
}
}
int flag = -1, num = 1;
//用最大的次数来限制
for (int i = 0; i < maxx * 10; ++i)
{
for (int j = 0; j < n; ++j)
{
//这一步有点像跳步,在多个数据之间来回跳步,但是只需要一个flag
if (w[j][i])
{
if (flag != j)
{
flag = j;
a[j][i] = num++;
}
else if (flag == j)
{
num++;
a[j][i] = num++;
}
}
}
}
for (int i = 0; i < n; ++i)
{
cout << "#" << i + 1 << endl;
//这一步输出操作,对于空格和换行很好的诠释了什么叫做想法
for (int j = 0; j < maxx * 10; ++j)
{
if (a[i][j] && (j + 1) % 10 == 0)
{
cout << a[i][j] << endl;
}
else if (a[i][j] && (j + 1) % 10)
{
cout << a[i][j] << ' ';
}
}
}
return 0;
}