poj 2501

题目连接:http://poj.org/submit?problem_id=2501

题目解析:这题没做出来,是因为时间格式的转换忘记了,其次是速度有的时候有,有的时候没有,不知道怎么解决,不过这题让我收获颇大

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<iostream>
#include<queue>
#include<stack>
#include<cstdlib>
using namespace std;
int cal(int h,int m,int s){
    return h*3600+m*60+s;
}
int main(){
    int h,m,s;
    double speed=0;
    double ans=0;
    int last=0;
    while (scanf("%d:%d:%d",&h,&m,&s)!=EOF){
        char ch=getchar();
        if (ch==' '){
            int a;
            scanf("%d",&a);
            int now=cal(h,m,s);
            ans+=(now-last)*speed;
            last=now;
            speed=a/3.6;
        }
		else
            printf("%02d:%02d:%02d %.2f km\n",h,m,s,(ans+(cal(h,m,s)-last)*speed)/1000);
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值