要分奇偶数
#include <stdio.h>
int n;
void sing()
{
int i, j, k;
for ( i = 1 ; i < n ; i += 2 )
printf("%d ", i);
printf("%d\n", n);
for ( i = 1 ; i < ((n+1)>>1); i++ )
{
k = 2;
while(k--)
{
for ( j = 2 * i ; j < n ; j++ )
printf("%d ", j);
printf("%d\n", n);
}
}
}
void dual()
{
int i, j, k;
for ( i = 1 ; i < n ; i++ )
printf("%d ", i);
printf("%d\n", n);
for ( i = 2 ; i < n ; i += 2 )
printf("%d ", i);
printf("%d\n", n);
for ( i = 3 ; i < n ; i += 2 )
{
k = 2;
while ( k-- )
{
for ( j = i ; j < n ; j++ )
printf("%d ", j);
printf("%d\n", n);
}
}
}
int main()
{
while (scanf("%d", &n), n)
{
int total= n*(n+1)/2;
if ( total & 1 )
printf("0\n");
else
{
printf("%d\n", n);
if ( n & 1 )
sing();
else
dual();
}
putchar(10);
}
return 0;
}