lpkkk @ 2024-02-15 15:57:25
#include<iostream>
using namespace std;
#include<vector>
int main()
{
int n = 1;
int N;
cin >> N;
vector<int>a;
int temp;
while (cin >> temp)
{
if (cin.peek() == '\n')
{
break;
}
a.push_back(temp);
}
a.push_back(temp);
int k = 0;
int b = 0;
for(int r=0;r<a.size();r++)
{
for (int j = 0; j < a[r]; j++)
{
cout << k;
b++;
if (b == N&&n!=N)
{
cout << endl;
b = 0;
n++;
}
}
if (k == 0)
{
k = 1;
}
else
{
k = 0;
}
}
return 0;
}
by Xia_Yu_Chen @ 2024-02-25 23:53:32
输入有问题
这种输入在本地exe中要用^Z(Ctrl + Z)结束
#include<iostream>
using namespace std;
#include<vector>
int main()
{
int n = 1;
int N;
cin >> N;
vector<int>a;
int temp;
while (cin >> temp) a.push_back(temp);//here
// int k = 0;
int b = 0;
for(int r=0;r<a.size();r++)
{
for (int j = 0; j < a[r]; j++)
{
cout << r % 2;
b++;
if (b == N&&n!=N)
{
cout << endl;
b = 0;
n++;
}
}
/*
if (k == 0)
{
k = 1;
}
else
{
k = 0;
}
*/
}
return 0;
}