| ||||||||||
| 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 | |||||||||
1654自测正确,提交waT_T!!求指正!!!#include<stdio.h>
#include<math.h>
#define N 20
char p[1000000];
int main()
{
double area[N];
int num,i,x,y,lastx,lasty;
char *path;
scanf("%d",&num);
for(i=0;i<num;i++)
{
path=p;
x=0;y=0;lastx=0;lasty=0;
area[i]=0;
scanf("%s",path);
while(*path!='5')
{
switch(*path)
{
case '8':y++;break;
case '6':x++;break;
case '4':x--;break;
case '2':y--;break;
case '7':x--;y++;break;
case '9':x++;y++;break;
case '3':x++;y--;break;
case '1':x--;y--;break;
}
area[i]+=abs(lastx*y-x*lasty)/2.0;
lastx=x;lasty=y;
path++;
}
}
for(i=0;i<num;i++)
{
if(area[i]!=(int)area[i])
printf("%.1lf\n",area[i]);
else
printf("%.0lf\n",area[i]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator