2176
求路程。
总路程=(t1-t0)*x1+....(tn-tn-1)*xn
运用时间段求。共有n组时间段,当n=-1时,跳出循环。
(很久没做题了!!!不能再这样了!!!100个啊!!!导师又在点我们了!!!科目三gogogo 单词gogogo 拉丁课gogogo 少吃gogogo 学化妆gogogo 做题gogogo)
2176
#include<iostream> using namespace std; int main(){ int n; while( cin>>n && n!=-1 ){ int s,t,p=0,distance=0; while( n-- && cin>>s>>t ){ distance += s*(t-p); p = t; } cout<<distance<<" miles"<<endl; } return 0; }
原文链接:https://www.cnblogs.com/iriswang/p/11084677.html