其他分享
首页 > 其他分享> > 1002 A+B for Polynomials (25分)

1002 A+B for Polynomials (25分)

作者:互联网

1002 A+B for Polynomials (25分)

#include<stdio.h>
int main()
{
    double a[1010]={0.0},b[1010]={0.0},c[1010]={0.0};
    int n1,n2;
    scanf("%d",&n1);
    for(int i=0;i<n1;i++){
        int a0;
        scanf("%d",&a0);
        scanf("%lf",&a[a0]);
    }
    scanf("%d",&n2);
    for(int i=0;i<n2;i++){
        int b0;
        scanf("%d",&b0);
        scanf("%lf",&b[b0]);
    }
    for(int i=0;i<1010;i++){
        c[i]=a[i]+b[i];
    }
    int ans=0;
    for(int i=0;i<1010;i++){
        if(c[i]!=0)ans++;
    }
    printf("%d",ans);
    for(int i=1005;i>=0;i--){
        if(c[i]!=0.0){
            printf(" %d %.1lf",i,c[i]);
        }
    }
    return 0;
}

  

标签:25,int,0.0,Polynomials,n1,1010,1002
来源: https://www.cnblogs.com/1012wenquan66/p/13680769.html