水题……
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
void getxy(int &x,int &y,char m)
{
switch(m)
{
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;
}
}
int main()
{
freopen("test.txt","r",stdin);
int T;
string str;
int i;
double area;
int x1,y1,x2,y2;
scanf("%d",&T);
while(T--)
{
cin>>str;
int n=str.length();
area=0;
x2=0,y2=0;
for(i=0;i<n;i++)
{
if(str[i]=='5')
break;
x1=x2,y1=y2;
getxy(x2,y2,str[i]);
area+=(x1*y2-x2*y1);
}
area=fabs(area);
area/=2;
if(area==(__int64)area) //小心数据溢出
printf("%.0lf\n",area);
else
printf("%.1lf\n",area);
}
return 0;
}