标签:
水题,用一个变量存一下上一个时间即可。
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 17698 | Accepted: 12433 |
Description
Speed in miles perhour Total elapsed time in hours 20 2 30 6 10 7
Input
Output
Sample Input
3 20 2 30 6 10 7 2 60 1 30 5 4 15 1 25 2 30 3 10 5 -1
Sample Output
170 miles 180 miles 90 miles
Source
1 //oimonster 2 #include<cstdio> 3 #include<cstdlib> 4 #include<iostream> 5 using namespace std; 6 int main(){ 7 int i,j,n,s,a,b,c; 8 scanf("%d",&n); 9 while(n!=-1){ 10 s=0; 11 c=0; 12 for(i=1;i<=n;i++){ 13 scanf("%d%d",&a,&b); 14 s=s+a*(b-c); 15 c=b; 16 } 17 printf("%d miles\n",s); 18 scanf("%d",&n); 19 } 20 return 0; 21 }
标签:
原文地址:http://www.cnblogs.com/oimonster/p/4292329.html