倒序输出时,i不能=maxn ,这是越界访问了,最大从maxn-1开始
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1000;
int main() {
int p[maxn] = { 0 }, A[maxn] = { 0 },e,x;
while (scanf("%d%d", &x, &e) != EOF) {
A[e] = x;
}
for (int i = 1; i < maxn; i++) {
p[i - 1] = A[i] * i;
}
for (int i = maxn-1; i >= 0; i--) {
if (p[i] != 0) cout << p[i] << " " << i<<" ";
}
system("pause");
return 0;
}