幻影学霸刘 @ 2019-09-21 12:14:53
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
int n,a[512];
string s;
cin>>n;
int i=0,j=0;
bool b=0;
while(cin>>a[i])
{
b++;
i++;
int k=0;
for(int j;k<a[i];k++,j++)
{
if(b==0)
{
s[j]='0';
}
else
{
s[j]='1';
}
}
}
int y=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cout<<s[y];
y++;
}
cout<<endl;
}
return 0;
}
by RayHaoRui @ 2019-09-21 12:16:42
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int n, num = 0, cnt = 0, temp;
cin >> n;
while (cin >> temp) {
for (int i = 0; i < temp; i++) {
cout << num;
cnt ++;
if (cnt == n) {
cout << endl;
cnt = 0;
}
}
num = 1 - num;
}
cout << endl;
return 0;
}