This time, you are supposed to find A+B where A and B are two polynomials.
C:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
float pm3[1001]={0};
float val;
int k1,k2,k3=0,i=0,idx;
scanf("%d",&k1);
for(i=0;i<k1;i++)
{
scanf("%d %f",&idx,&val);
pm3[idx]+=val;
}
scanf("%d",&k2);
for(i=0;i<k2;i++)
{
scanf("%d %f",&idx,&val);
pm3[idx]+=val;
}
for(i=0;i<1001;i++)
{
if(pm3[i]!=0) k3++;
}
printf("%d",k3);
for(i=1000;i>=0;i--)
{
if(pm3[i]!=0)
{
printf(" %d %.1f",i,pm3[i]);
}
}
return 0;
}