• 716 一元多项式求导


    #include <iostream>
    #include <stdio.h>
    #include <sstream>
    using namespace std;
    typedef struct note
    {
        int xs,zs;
        struct note *next;
    }note;
    note* CreatList()
    {
        note *head,*q,*p;
        head=(note*)malloc(sizeof(note));
        head->next=NULL;
        q=head;
        string b;
        getline(cin,b);
        stringstream ss(b);
        int aa,bb;
        while(ss>>aa>>bb)
        {
            p=(note*)malloc(sizeof(note));
            p->xs=aa;
            p->zs=bb;
            p->next=NULL;
            q->next=p;
            q=p;
        }
        return head;
    }
    note* QD(note* p)
    {
        note *head;
        head=p;
        while(p!=NULL)
        {
            if(p->zs!=0)
            {
                p->xs=p->xs*p->zs;
                p->zs=p->zs-1;
            }
            else
            {
                p->xs=0;
                p->zs=0;
            }
            p=p->next;
        }
        return head;
    }
    void Print(note* p)
    {
        int f=0;
        p=p->next;
        if(p->xs==0)
        cout<<"0 0"<<endl;
        else
        {
            while(p!=NULL)
            {
                if(!f)
                {
                    cout<<p->xs<<" "<<p->zs;
                    f=1;
                }
                else
                {
                    if(p->xs!=0)
                    cout<<" "<<p->xs<<" "<<p->zs;
                }
                p=p->next;
                
            }
            cout<<endl;
        }
    }
    int main()
    {
        note *p=CreatList();
        note *p1=QD(p);
        Print(p1);
    }
    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
        int a,b,f=0;
        while(scanf("%d %d",&a,&b))
        {
            if(b)
            {
                if(f)printf(" ");
                printf("%d %d",a*b,b-1);
                f=1;
            }
            if(getchar()!=' ')break;
        }
        if(!f)printf("0 0");
        cout<<endl;
    }
    #include <stdio.h>
    #include <iostream>
    #include <sstream>
    using namespace std;
    
    struct note
    {
        int xs,zs;
    }a[1000];
    int main()
    {
        string b;
        getline(cin,b);
        stringstream ss(b);
        int aa,bb,i=0;
        while(ss>>aa>>bb)
        {
            a[i].xs=aa;
            a[i].zs=bb;
            //cout<<a[i].xs<<" "<<a[i].zs<<endl;
            i++; 
        }
        int c=0;
        for(int j=0;j<i;j++)
        {
            if(a[j].zs>=1)
            {
                a[j].xs=a[j].xs*a[j].zs;
                a[j].zs=a[j].zs-1;
            }
            else
            {
                a[j].xs=0;
                a[j].zs=0;
                c++;
            }
        }
        int f=0;
        for(int j=0;j<i-c;j++)
        {
            f=1;
            j==0?cout<<a[j].xs<<" "<<a[j].zs:cout<<" "<<a[j].xs<<" "<<a[j].zs;    
        }
        if(f)
        cout<<endl;
        else
        cout<<"0 0"<<endl;
    }
  • 相关阅读:
    python多版本切换
    python之禅
    Python int与string之间的转化
    pycharm工具使用
    python学习路线图
    traceback.print_exc()的用法
    他人学习Python感悟
    【西北师大-19软工】第十三、十四次作业汇总暨期末总结
    【西北师大-19软工】第十二次作业成绩汇总
    第十七周助教工作总结——NWNU李泓毅
  • 原文地址:https://www.cnblogs.com/xyfs99/p/10349071.html
Copyright © 2020-2023  润新知