| ||||||||||
| 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 | |||||||||
牛兄牛弟们,错哪了?#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
int len,speed=0,h2,m2,s2,h1,m1,s1;
char pzj[50];
double t,ldis,dis=0; //忘初始化 了
char sor[50]={0};
while(gets(pzj)!=NULL)
{
len=strlen(pzj);
if(len>=10)
{
h2=(sor[0]-'0')*10+sor[1]-'0';
m2=(sor[3]-'0')*10+sor[4]-'0';
s2=(sor[6]-'0')*10+sor[7]-'0';
h1=(pzj[0]-'0')*10+pzj[1]-'0';
m1=(pzj[3]-'0')*10+pzj[4]-'0';
s1=(pzj[6]-'0')*10+pzj[7]-'0';
t=(h1-h2)+(m1-m2)/60.0+(s1-s2)/3600.0;
dis=t*speed;
strcpy(sor,pzj);
h2=(sor[0]-'0')*10+sor[1]-'0';
m2=(sor[3]-'0')*10+sor[4]-'0';
s2=(sor[6]-'0')*10+sor[7]-'0';
speed=atoi(sor+9);
ldis=dis;
}
else
{
dis=0;
h1=(pzj[0]-'0')*10+pzj[1]-'0';
m1=(pzj[3]-'0')*10+pzj[4]-'0';
s1=(pzj[6]-'0')*10+pzj[7]-'0';
t=(h1-h2)+(m1-m2)/60.0+(s1-s2)/3600.0;
dis=t*speed;
if(strcmp(pzj,"00:00:01")==0)
printf("%s 0.00 km\n",pzj);
else
printf("%s %.2f km\n",pzj,dis+ldis);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator