【B1010/模拟】多项式求导(巧用数组)
作者:互联网
倒序输出时,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;
}
标签:倒序,EOF,int,B1010,d%,maxn,求导,include,巧用 来源: https://blog.csdn.net/qq_41427793/article/details/123239186