| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1421 人关注过本帖, 1 人收藏
标题:此题结构复杂, 内容繁琐, 小弟无从下手啊, 求解答
只看楼主 加入收藏
束缚袭霜
Rank: 2
等 级:论坛游民
帖 子:21
专家分:30
注 册:2010-7-4
收藏
得分:0 
int newbook(BOOK *lastnode,int *n){        //lastnode is the lastnode of booklist , n is the number of books
    BOOK *newnode;

    /*  if expend the struct book , add sth here  */

    newnode=(BOOK *)malloc(sizeof(BOOK));
    if(newnode==NULL)return 0;
    *n=*n+1;
    newnode->id=*n;
    newnode->state=1;
    newnode->next=NULL;
    lastnode->next=newnode;
    lastnode=newnode;                    //replace the lastnode;
    return 1;
}                       //in main(),test newbook() and decide append lastnode to book.txt or not

int deletebook(BOOK *booklist,int id){
    BOOK *book=booklist;
    while(book){
        if(book->id==id){
            book->state=-1;
            return 1;}
        book=book->next;
    }
    return 0;
}    /*another solution is "blacklist" ,then when you init ,just delete that node*/

int newlicense(LICENSE *lastnode , int *n){            //see newbook()
    LICENSE *newnode;
    newnode=(LICENSE *)malloc(sizeof(LICENSE));
    if(newnode==NULL)return 0;
    *n=*n+1;
    newnode->id=*n;
    newnode->holding=0;
    newnode->next=NULL;
    lastnode->next=newnode;
    lastnode=newnode;
    return 1;
}
int deletelicense(LICENSE *llist,int id){        //see deletebook()
    /* infact we will never delete ,so there is no llist->state ....lol.... */
    return 1;
}

int newborrow(BRECORD *lastnode){
    int bookid,licenseid;
    BRECORD *newnode;
    printf("INPUT LICENSE ID & BOOK ID:")
    scanf("%d %d",&licenseid,&bookid);

    /*if you decide to check the record ,do it ,then you need two para:BOOK *booklist and LICENSE *list;*/
    /* but in fact ,we only borrow when we realy get the book */
    /* a machine do it better,so do you need a confirm? */

    newnode=(BRECORD *)malloc(sizeof(BRECORD));
    if(newnode==NULL)return 0;
    newnode->bookid=bookid;
    newnode->licenseid=licenseid;
    newnode->btime=time();
    newnode->next=NULL;
    lastnode->next=newnode;
    lastnode=newnode;
    return 1;   
}                            /* then ,test and append */
------------------------------------------------------------------
I think I need a new struct of BRECORD and RRECORD;for the easier operation on newborrow and newreturn;

我是自学的,所以……
2010-07-07 10:25
风飏
Rank: 1
等 级:新手上路
帖 子:16
专家分:4
注 册:2010-7-17
收藏
得分:0 
是用C语言么  只要程序 还是要系统啊
2010-07-17 19:13
风飏
Rank: 1
等 级:新手上路
帖 子:16
专家分:4
注 册:2010-7-17
收藏
得分:0 
我们大一的时候就是这个程序  大二的时候就让我们做成系统实现
2010-07-17 19:14
快速回复:此题结构复杂, 内容繁琐, 小弟无从下手啊, 求解答
数据加载中...
 
   



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

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