相关代码 |
|
/* This Code is Submitted by wywcgs for Problem 1688 on 2005-03-05 at 15:55:07 */ #include int main() { int speed[10] = {0}, time[10] = {0}, distance = 0; int n, i; while(scanf("%d", &n) == 1){ if(n == -1){ return 0; }else{ for(i = 0; i < n; i++){ scanf("%d %d", &speed[i], &time[i]); if(i == 0){ distance = speed[0] * time[0]; }else{ distance += speed[i] * (time[i] - time[i-1]); } } printf("%d miles\n", distance); } } return 0; }
相关资源 |
|