Follows 392.c (Total 57 lines):

/* @JUDGE_ID:4461XX 392 C */
/* A */
#include<math.h>
#include<stdio.h>
int coe[9] ; /*coefficient */
void input( void )
{
	int i ;
	for( i=7 ; i>=0 ; i-- )
		scanf( "%d" , &coe[i] ) ;
}
void go_print( int first , int i )
{
	if( first ){
		if( coe[i] == -1 )
			putchar( '-' ) ;
		else if( coe[i] != 1 )
			printf( "%d" , coe[i] ) ;
	}
	else{
		if( coe[i] > 0 )
			printf( " %c " , '+' ) ;
		else printf( " %c " , '-' ) ;
		if( abs( coe[i] ) != 1 ) printf( "%d" , abs( coe[i] ) ) ;
	}
	if( i == 1 ) putchar( 'x' ) ;
	else printf( "x^%d" , i ) ;
}
void print_for_exp0( int first )
{
	if( first ) printf( "%d" , coe[0] ) ;
	else{
		if( coe[0] > 0 ) printf( " + " ) ;
		else printf( " - " ) ;
		printf( "%d" , abs( coe[0] ) ) ;
	}
}
void main( void )
{
	int print , i , first ;
	while( scanf( "%d" , &coe[8] ) == 1 ){
		input() ;
		for( first=1 , print=0 , i=8 ; i>0 ; i-- ) /* exp >= 1 */
			if( coe[i] ){
				print = 1 ;
				go_print( first , i ) ;
				if( first ) first = 0 ;
			}
		if( coe[0] ){ /* exp == 0 */
			print_for_exp0( first ) ;
			print = 1 ;
		}
		if( !print ) puts( "0" ) ;
		else putchar( '\n' ) ;
	}
}
/* @END_OF_SOURCE_CODE */

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