#include
#include
#include
void sort(int *a,int n,int N)
{
int x = 0;
for (int i = n; i < N - 1; i++)
{
for (int j = i + 1; j < N; j++)
{
if (a[i] / 10 < a[j] / 10)
{
x = a[i];
a[i] = a[j];
a[j] = x;
}
}
}
}

int main()
{
int N;
int *a = (int *)malloc(sizeof(int) * N);
int n;
int sum = 0;
int b[N][N];
printf("请输入池塘个数:");
scanf("%d", &N);
for (int i = 0; i < N; i++)
{
printf("请输入第%d个数:", i + 1);
scanf("%d", &a[i]);
if (a[i] >= N)
{
printf("NO");
}
else
{
sum += a[i];
a[i] = a[i] * 10 + i;
}
}
if (sum % 2 != 0)
{
printf("NO");
}
else
{
for (int i = 0; i < N-1; i++)
{
sort(a,i,N);
for (int j = i + 1; j < a[i] / 10 + i+1; j++)
{
if (a[j] / 10 != 0)
{
a[i] %= 10;
a[j] = (a[j] / 10 - 1) * 10 + a[j] % 10;
b[a[i]%10][a[j]%10]=1;
}
else
{
break;
}
}
}
n = 0;
for (int i = 0; i < N; i++)
{
if (a[i] / 10 == 0)
{
n++;
}
}
if (N == n)
{
printf("YES");
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
printf("%d", b[i][j]);
}
printf("\n");
}
}
else
{
printf("NO");
}
}
return 0;
}

sakgh 回复贵阳老马马善福专业维修游泳池堵漏防水工程: 初学者，真心不懂，求指教。
3 个月之前 回复