| ||||||||||
| 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>
using namespace std;
int main(){
int a,b,tot,n,last;
cin>>n;
while(n!=-1)
{
last=tot=0;
for(int i=0;i<n;i++)
{
cin>>a>>b;
tot=tot+(b-last)*a;
last=b;
}
cout<<tot<<" miles"<<endl;
cin>>n;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator