Follows 699.c (Total 74 lines):

/* @JUDGE_ID:4461XX 699 C */
/* A */
#include<stdio.h>
#include<stdlib.h>
struct node{
	int value ;
	struct node *left ;
	struct node *right ;
} ;
void getleft( struct node *middle ) ;
void getright( struct node *middle ) ;
void print( struct node *head )
{
	printf( "%d" , head->value ) ;
	for( head=head->right ; head ; head=head->right )
		printf( " %d" , head->value ) ;
	putchar( '\n' ) ;
	putchar( '\n' ) ;
}
void main( void )
{
	int i , n ;
	struct node *head ;
/* freopen( "C:\\windows\\desktop\\699.in" , "r" , stdin ) ; */
/*	freopen( "C:\\windows\\desktop\\699.out" , "w" , stdout ) ;*/
	for( i=1 ; ; i++ ){
		head = ( struct node * )malloc( sizeof( struct node ) ) ;
		head->left = head->right = NULL ;
		scanf( "%d" , &head->value ) ;
		if( head->value == -1 ) break ;
		printf( "Case %d:\n" , i ) ;
		getleft( head ) ;
		for( ; head->left ; head=head->left ) ;
		print( head ) ;
	}
}
void getright( struct node *middle )
{
	struct node *test ;
	int n ;
	scanf( "%d" , &n ) ;
	if( n == -1 ) return ;
	else{
		if( middle->right ) test = middle->right ;
		else{
			test = ( struct node * )malloc( sizeof( struct node ) ) ;
			test->value = 0 ;
			test->right = NULL ;
			test->left = middle ;
			middle->right = test ;
		}
		test->value += n ;
		getleft( test ) ;
	}
}
void getleft( struct node *middle )
{
	struct node *test ;
	int n ;
	scanf( "%d" , &n ) ;
	if( n != -1 ){
		if( middle->left ) test = middle->left ;
		else{
			test = ( struct node * )malloc( sizeof( struct node ) ) ;
			test->value = 0 ;
			test->left = NULL ;
			test->right = middle ;
			middle->left = test ;
		}
		test->value += n ;
		getleft( test ) ;
	}
	getright( middle ) ;
}

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