Follows 202.c (Total 41 lines):

/* @JUDGE_ID:4461XX 202 C */
/* A */
#include<stdio.h>
struct data{
	int time ;
	int more ;
}data[10000] ;
void print( int begin , int end )
{
	int i , count ;
	for( i=0 ; i<begin ; i++ ) printf( "%d" , data[i].time ) ;
	putchar( '(' ) ;
	for( i=begin , count=0 ; i<end && count<50 ; i++ , count++ )
		printf( "%d" , data[i].time ) ;
	if( count == 50 ) printf( "..." ) ;
	putchar( ')' ) ;
	printf( "\n   %d = number of digits in repeating cycle\n\n" , end-begin ) ;
}
void main( void )
{
	int m , n , point , i , yes ;
	while( scanf( "%d %d" , &m , &n ) == 2 ){
		printf( "%d/%d = %d." , m , n , m/n ) ;
		for( m%=n , yes=point=0 ; ; point++ ){
			for( i=point-1 ; i>=0 ; i-- )
				if( data[i].time==(m*10)/n && data[i].more==(m*10)%n ){
					print( i , point ) ;
					yes = 1 ;
					break ;
				}
			if( yes ) break ;
			if( !m ){
				data[point].time = 0 ;
				print( point , point+1 ) ;
				break ;
			}
			data[point].time = ( m * 10 ) / n ;
			data[point].more = m = ( m * 10 ) % n ;
		}
	}
}

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