| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
HELP!!! Is there any problem in this program?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator