Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:HELP!!! Is there any problem in this program?

Posted by yuqi1314 at 2008-10-04 15:21:39 on Problem 1654
In Reply To:HELP!!! Is there any problem in this program? Posted by:baofenye at 2004-10-25 22:21:45
> #include <stdio.h>
> #include <math.h>
> int main ( void )
> {
>     int i, n, x, y, xx, yy;
>     double carea, area;
>     char ch;
> 
>     scanf ( "%d", &n );
>     for ( i = 0; i < n; i ++ )
>     {
> 	x = y = 0;
> 	carea = area = 0;
> 
> 	while ( 1 )
> 	{
> 	    xx = x;
> 	    yy = y;
> 	    scanf ( "%c", &ch );
> 	    if ( ch == '5' ) break;
> 	    switch ( ch )
> 	    {
> 		case '1':	x --;    y --;    break;
> 		case '2':	y --;	      	  break;
> 		case '3':	x ++;    y --;    break;
> 		case '4':	x --;             break;
> 		case '6':	x ++;             break;
> 		case '7':	x --;    y ++;    break;
> 		case '8':	y ++;             break;
> 		case '9':	x ++;    y ++;    break;
> 	    }
> 	    carea += xx * y - yy * x; 
> 	    if ( x == 0 && y == 0 ) 
> 	    {
> 		area += fabs ( carea );
> 		carea = 0;
> 	    }
> 	}
> 	area /= 2;
> 	printf ( "%.0f", area );
> 	if ( ceil ( area ) - area > 0.4 )  printf ( ".5" );
> 	printf ( "\n" );
>     }
>     return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator