求助大佬不知道哪里错了,数组,c++
  • 板块P1319 压缩技术
  • 楼主Etayo
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/12/30 21:08
  • 上次更新2023/12/30 23:55:33
查看原帖
求助大佬不知道哪里错了,数组,c++
1027350
Etayo楼主2023/12/30 21:08
#include<iostream>
#include<iomanip>
#include<vector>
#include<cmath>
using namespace std;

int main()
{
	int n,map[40000],k[400000];
	cin >> n;
	int t = 0;
	int i = 0;
	for (int p = 0; p < n; p++)
	{
		cin >> k[p];
	}
	int p = 0;
	while (i<=n*n)
	{	
		if (t%2==0)
		{
			for (; i < i+k[p]; i++)
			{
				map[i] = 0;
			}
		}
		else
		{
			for (; i < i+k[p]; i++)
			{
				map[i] = 1;
			}
		}
		t++;
		i++;
		p++;
	}
	int s = 0;
	for (int j = 0; j < n*n; j++)
	{
		cout << map[j];
		s++;
		if (s%n==0)
		{
			cout << endl;
		}
	}
	return 0;
}
2023/12/30 21:08
加载中...