标签:数组下标 -o 导数 algo 粘贴 数字 for cpp clu
请勿粘贴
以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。
以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。
3 4 -5 2 6 1 -2 0
12 3 -10 1 6 0
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
struct node
{
int m,n;
};
const int maxn=1010;
node res[maxn];
//思路依旧是 用数组下标代表指数
int main()
{
int a,b;
int num=0;
while(scanf("%d%d",&a,&b)!=EOF)
{
res[num].m=a*b;
if(abs(b))
{
res[num].n=b-1;
num++;
}
}
if(num==0)
cout<<0<<" "<<0<<endl;
for(int i=0;i<num;i++)
{
if(i==num-1)
cout<<res[i].m<<" "<<res[i].n<<endl;
else
cout<<res[i].m<<" "<<res[i].n<<" ";
}
}
标签:数组下标 -o 导数 algo 粘贴 数字 for cpp clu
原文地址:http://www.cnblogs.com/masterchd/p/7517843.html