| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 377 人关注过本帖
标题:编译不出来?????
取消只看楼主 加入收藏
czwx
Rank: 1
等 级:新手上路
帖 子:6
专家分:3
注 册:2015-10-4
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:0 
编译不出来?????
#include<stdio.h>
#include<malloc.h>
struct linklist
{
     int no,price,num;
     struct linklist *next;
};
void create(struct linklist *h)
{   h=NULL;
    int a,b,c;
    struct linklist *p,*q;
    q=h;
    printf("请依次输入商品的编号、单价、数量,以0 0 0作为输入结束的标志\n");
    scanf("%d%d%d",&a,&b,&c);
    while((a!=0)||(b!=0)||(c!=0))
    {   
        p=(struct linklist *)malloc(sizeof(struct linklist));
        p->no =a;
        p->price =b;
        p->num =c;p->next=NULL;
        q->next =p;
        q=p;
        scanf("请继续输入:\n %d%d%d",&a,&b,&c);
    }
 
}
int renew(struct linklist *h)
{    int i;
     struct linklist *p;
     for(p=h;p!=NULL;p=p->next )
     {   
         if(p->no ==1004)
         { for(i=1004;i<1007;i++)
              {
                    p->num =0;
                    p=p->next ;
              }

            return 1;
         }

     }
   
}
int del(struct linklist *h)
{     

   struct linklist *p,*q;
   
   for(p=h;p!=NULL;p=p->next )
   {
      
       if(p->no ==1005)
       {
           q->next =p->next ->next ;
           return 1;
       }
       q=p;
   }
}
int init(struct linklist *h)
{   
    int i=1006;
    struct linklist *p,*q;
    p=h;
    while(p->no !=1004)
        p=p->next ;
    q=(struct linklist *)malloc(sizeof(struct linklist));
    q->no =1005;
    q->num =40;
    q->price =55;
    for(q=q->next ;q!=NULL;q=q->next )
    {   
         q->no =i;
         i++;
    }
    return 1;
}
void collect(struct linklist *h,int *a,int *b)
{
   
    struct linklist *p;
    for(p=h;p!=NULL;p=p->next )
    {
        a=p->num +a;
        b=p->price*p->num  +b;
    }

}
void main()
{
    int a=0,b=0;
    struct linklist *h;
    h=(struct linklist *)malloc(sizeof(struct linklist));
    create(h);
   
    if(renew(h)==1)
        printf("数据已更新\n");
    if(renew(h)==1)
        printf("删除成功\n");
    if(init(h)==1)
        printf("插入成功\n");

    collect(h,&a,&b);
    printf("总数量、总价格为:\n %d    %d",a,b);
}

搜索更多相关主题的帖子: include create price 
2015-10-28 22:44
快速回复:编译不出来?????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014823 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved