duanyuchen @ 2018-05-19 20:22:34
using namespace std; int b[500]; int main() { int n; cin >> n; for (int i = 0; i < 2 n; i++) { cin >> b[i]; } int t = 0; for (int i = 0; i < 2 n; i++) { if (i % 2 == 0) { while (b[i]--) { if (t == n) { cout << endl; t = 0; } cout << 0; t++; } } else { while (b[i]--) { if (t == n) { cout << endl; t = 0; } cout << 1; t++; } }
}
system("pause");
return 0;
}
by duanyuchen @ 2018-05-19 20:23:53
#include<iostream>
using namespace std;
int b[500];
int main()
{
int n;
cin >> n;
for (int i = 0; i < 2 * n; i++)
{
cin >> b[i];
}
int t = 0;
for (int i = 0; i < 2 * n; i++)
{
if (i % 2 == 0)
{
while (b[i]--)
{
if (t == n)
{
cout << endl;
t = 0;
}
cout << 0;
t++;
}
}
else
{
while (b[i]--)
{
if (t == n)
{
cout << endl;
t = 0;
}
cout << 1;
t++;
}
}
}
system("pause");
return 0;
}
by duanyuchen @ 2018-05-19 20:25:17
输出到后面就不再输出了
by Shui_Dream @ 2018-07-28 08:37:23
2*n是什么鬼
by Shui_Dream @ 2018-07-28 08:37:45
#include<bits/stdc++.h>
using namespace std;
int n,a[10005],f,k,sum;
int main()
{
cin>>n;
for(int i=1;i>0;i++)
{
cin>>a[i];
for(int j=1;j<=a[i];j++)
{
sum++;
if(sum>=n*n)
{
f=i;
a[i]=j;
i=0;
break;
}
}
if(i==0) break;
}
for(int i=1;i<=f;i++)
{
for(int j=1;j<=a[i];j++)
{
if(i%2==1) cout<<0;
else cout<<1;
k++;
if(k>=n)
{
k=0;
cout<<endl;
}
}
}
return 0;
}