很简单的一题,直接上源码。 #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_PAIRS_SIZE 11 int pairs[MAX_PAIRS_SIZE][2]; int main(int argc, char *argv[]) { pairs[0][0] = 0; pairs[0][1] = 0; while(1) { int n; scanf("%d", &n); if(-1 == n) break; int totalMiles = 0; int i; for(i = 1; i <= n; ++i) { scanf("%d%d", &pairs[i][0], &pairs[i][1]); totalMiles += pairs[i][0] * (pairs[i][1] - pairs[i-1][1]); } printf("%d miles/n", totalMiles); } system("PAUSE"); return 0; }