Follows 291.c (Total 36 lines):

/* @JUDGE_ID:4461XX 291 C */
/* A */
#include<stdio.h>
int arr[5][5]={ 0 , 1 , 1 , 0 , 1 ,
					 1 , 0 , 1 , 0 , 1 ,
					 1 , 1 , 0 , 1 , 1 ,
					 0 , 0 , 1 , 0 , 1 ,
					 1 , 1 , 1 , 1 , 0 } ;
int way[9] ;
void print( void )
{
	int i ;
	for( i=0 ; i<9 ; i++ ) printf( "%d" , way[i]+1 ) ;
	putchar( '\n' ) ;
}
void house( int i , int level )
{
	int j ;
	if( level == 9 ) print() ;
	else{
		for( j=0 ; j<5 ; j++ )
			if( arr[i][j] == 1 ){
				way[level] = j ;
				arr[j][i] = arr[i][j] = 2 ;
				house( j , level+1 ) ;
				arr[j][i] = arr[i][j] = 1 ;
			}
	}
}
void main( void )
{
	int i ;
/*	freopen( "c:\\windows\\desktop\\291.out" , "w" , stdout ) ;*/
	way[0] = 0 ;
	house( 0 , 1 ) ;
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com