题解
2023-06-24 14:01:12
发布于:上海
23阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct p
{
int num;
int flag = 0;
};
int n;
int main()
{
cin >> n;
p s[n + 1];
vector<int>a[n + 1];
int maxn = 0;
for(int i = 1; i <= n; i ++)
{
int number;
cin >> number;
s[i].num = number * 10;
if(maxn < s[i].num) maxn = s[i].num;
}
int fl = n;
int now = 0;
for(int i = 1; i <= maxn; i ++)
{
for(int j = 1; j <= n; j ++)
{
if(s[j].num == 0 && s[j].flag == 0)
{
s[j].flag = 1;
fl --;
continue;
}
else if(s[j].num == 0) continue;
else
{
if(fl == 1)
{
now += 2;
}
else now ++;
s[j].num --;
a[j].push_back(now);
}
}
}
for(int i = 1; i <= n; i ++)
{
cout << "No." << i << endl;
for(int j = 0; j < a[i].size(); j ++)
{
if((j + 1) % 10 == 0) cout << a[i][j] << endl;
else cout << a[i][j] << " ";
}
}
}
全部评论 1
👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
2023-07-22 来自 江苏
0
有帮助,赞一个