半哩吧 关注:9贴子:2,531
  • 23回复贴,共1

开一个说说贴

只看楼主收藏回复

随便说点什么


IP属地:上海来自iPhone客户端1楼2016-02-04 09:21回复
    鄙人年十九,韶居于夷陵,因名含辰明,因以为号焉。敏思好言,不攀绩利。好读书,除却应试,不求甚解;每有会意,便欣然闭目。性自得,适挑时而娱。亲朋治余如此,或呼余同乐之;呼则必达,风雨无阻,曾不吝情去留。踢足击篮,皆有所好;游鱼竞速,亦有涉及。常著文章自娱,以表感慨。忘怀得失,以此自今。


    IP属地:上海来自iPhone客户端2楼2016-02-04 09:23
    收起回复
      。。。贴文言文我老是要很努力地逼迫自己看下去。。。


      3楼2016-02-04 22:40
      收起回复
        突然发现我现在是半毫米了终于来到了常见的单位


        IP属地:上海来自iPhone客户端4楼2016-02-04 23:07
        收起回复
          #include<stdio.h>
          #include<malloc.h>
          /*#define LEN sizeof(struct Node)*/
          typedef struct Node{
          float coef;
          int expn;
          struct Node *next;
          }Node,*polynomial;
          void creatpoly(polynomial &head,int m)
          { int i;
          polynomial p,pa;
          head=(polynomial)malloc(sizeof(Node));
          head->next=NULL;
          p=head;
          for(i=0;i<m;i++)
          {
          pa=(polynomial)malloc(sizeof(Node));
          printf("请输入第%d项的系数与指数:",i+1);
          scanf("%f%d",&pa->coef,&pa->expn);
          pa->next=NULL;
          p->next=pa;
          p=p->next;
          }
          }
          void addpoly(polynomial &pa,polynomial &pb)
          {
          polynomial ha,hb,hc,p;
          ha=pa->next;
          hb=pb->next;
          hc=pa;
          while(ha&&hb)
          {
          if(ha->expn<hb->expn)
          {hc->next=ha;ha=ha->next;hc=hc->next;}
          else if(ha->expn>hb->expn)
          {hc->next=hb;hb=hb->next;hc=hc->next;}
          else
          {
          ha->coef=ha->coef+hb->coef;
          if(ha->coef)
          {
          hc->next=ha;ha=ha->next;hc=hc->next;
          p=hb;
          hb=hb->next;/*free(p);*/
          }
          else
          {p=ha;ha=ha->next;/*free(p);*/
          p=hb;hb=hb->next;/*free(p);*/}
          }
          if(ha) hc->next=ha;
          if(hb) hc->next=hb;
          if(!ha&&!hb) hc->next=NULL;
          /*free(pb);*/
          }
          }
          void printfpoly(polynomial p)
          {
          polynomial q;
          q=p->next;
          while(q->next)
          {printf("%gX^%d+",q->coef,q->expn);
          q=q->next;
          }
          printf("%gX^%d",q->coef,q->expn);
          printf("\n");
          }
          void main()
          {
          int m,n;
          polynomial pa,pb,pc;
          printf("a个数:");
          scanf("%d",&m);
          creatpoly(pa,m);
          printf("La=");
          printfpoly(pa);
          printf("b个数:");
          scanf("%d",&n);
          creatpoly(pb,n);
          printf("Lb=");
          printfpoly(pb);
          addpoly(pa,pb);
          printf("Lc=");
          printfpoly(pa);
          }


          IP属地:上海来自iPhone客户端5楼2016-03-04 11:00
          回复
            #include<stdio.h>
            #include<malloc.h>
            /*#define LEN sizeof(struct Node)*/
            typedef struct Node{
            float coef;
            int expn;
            struct Node *next;
            }Node,*polynomial;
            void creatpoly(polynomial &head,int m)
            { int i;
            polynomial p,pa;
            head=(polynomial)malloc(sizeof(Node));
            head->next=NULL;
            p=head;
            for(i=0;i<m;i++)
            {
            pa=(polynomial)malloc(sizeof(Node));
            printf("请输入第%d项的系数与指数:",i+1);
            scanf("%f%d",&pa->coef,&pa->expn);
            pa->next=NULL;
            p->next=pa;
            p=p->next;
            }
            }
            void addpoly(polynomial &pa,polynomial &pb)
            {
            polynomial ha,hb,hc,p;
            ha=pa->next;
            hb=pb->next;
            hc=pa;
            while(ha&&hb)
            {
            if(ha->expn<hb->expn)
            {hc->next=ha;ha=ha->next;hc=hc->next;}
            else if(ha->expn>hb->expn)
            {hc->next=hb;hb=hb->next;hc=hc->next;}
            else
            {
            ha->coef=ha->coef+hb->coef;
            if(ha->coef)
            {
            hc->next=ha;ha=ha->next;hc=hc->next;
            p=hb;
            hb=hb->next;/*free(p);*/
            }
            else
            {p=ha;ha=ha->next;/*free(p);*/
            p=hb;hb=hb->next;/*free(p);*/}
            }
            if(ha) hc->next=ha;
            if(hb) hc->next=hb;
            if(!ha&&!hb) hc->next=NULL;
            /*free(pb);*/
            }
            }
            void printfpoly(polynomial p)
            {
            polynomial q;
            q=p->next;
            while(q->next)
            {printf("%gX^%d+",q->coef,q->expn);
            q=q->next;
            }
            printf("%gX^%d",q->coef,q->expn);
            printf("\n");
            }
            void main()
            {
            int m,n;
            polynomial pa,pb,pc;
            printf("a个数:");
            scanf("%d",&m);
            creatpoly(pa,m);
            printf("La=");
            printfpoly(pa);
            printf("b个数:");
            scanf("%d",&n);
            creatpoly(pb,n);
            printf("Lb=");
            printfpoly(pb);
            addpoly(pa,pb);
            printf("Lc=");
            printfpoly(pa);
            }


            IP属地:上海来自iPhone客户端6楼2016-03-11 09:55
            回复
              #include<stdio.h>
              #include<malloc.h>
              #define LEN sizeof(struct LNode)
              typedef struct LNode
              { int data;
              struct LNode *next;
              }LNode, *Linklist;
              int creat(Linklist &hd,int n)
              { Linklist pf,pb;int i;
              for(i=0;i<n;i++)
              { pb=(Linklist)malloc(LEN);
              printf("input data:");
              scanf("%d",&pb->data);
              if(i==0) pf=hd=pb;
              else pf->next=pb;
              pb->next=NULL;
              pf=pb;
              }
              return 1;
              }
              int display(Linklist hd)
              { Linklist ps;
              int i=1;ps=hd;printf("\nOupput linklist data:\n");
              if(ps==NULL)printf(" The linked list is empty!\n");
              while(ps!=NULL)
              { printf("No:%d data=%d\n",i++,ps->data);
              ps=ps->next;
              }
              return i-1;
              }
              int add(Linklist &hd,int b/*加在第b个后*/,int c/*所加的数*/)
              { Linklist p=hd,n;int i;
              n=(Linklist)malloc(LEN);
              n->data=c;
              if(b==0)
              { n->next=hd;
              hd=n;
              }
              else
              { for(i=0;i<b-1;i++)
              p=p->next;
              n->next=p->next;p->next=n;
              }
              return 1;
              }
              int Union(Linklist L1,Linklist L2,Linklist &L3)
              { int i,j,k;
              Linklist p=L1,q=L2;
              for(k=1;p->next!=NULL;p=p->next,k++);
              L3=L1;
              for(q=L2,i=1;q!=NULL;q=q->next,i++)
              { p=L1;
              for(j=1;p!=NULL;p=p->next,j++)
              if(p->data==q->data)break;
              if(p==NULL) add(L3,k++,q->data);
              }
              return 1;
              }
              void main()
              { Linklist L1,L2,L3;
              int n;
              printf("请输入链表L1的节点数:");
              scanf("%d",&n);fflush(stdin);
              creat(L1,n);
              display(L1);
              printf("请输入链表L2的节点数:");
              scanf("%d",&n);fflush(stdin);
              creat(L2,n);
              display(L2);
              Union(L1,L2,L3);
              printf("L1与L2的并集L3为:");
              display(L3);
              }


              IP属地:上海来自iPhone客户端7楼2016-03-11 09:59
              回复
                上面那两层是啥


                来自Android客户端8楼2016-03-25 11:35
                收起回复