Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 2049|回复: 6
打印 上一主题 下一主题

救命啊!C programing-LINKED LIST!

[复制链接]

9

主题

0

好友

4160

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

跳转到指定楼层
1#
发表于 2009-7-26 04:02 PM |只看该作者 |倒序浏览
谢谢各位上次帮我解决assessment1的问题。。。
现在希望大家能帮我这更难的assessment2啊,快疯了!
1.Write a C program to read a list of books from a file and create a linked list to store them. The purpose of this program is to keep track of the books kept in a shelf. The shelf is a three-tier shelf and each tier can store up to 4500 pages maximum. The books are kept in alphabetical order (ascending).

Your program should provide the following functions:-
a.        Print the detail of all books.
b.        Insert new book to the shelf in alphabetical order. However, if the first-tier is full, you must put the book into the second tier.
c.        Remove a book from the list.
d.        Search for a book using the book title, return the tier where the book is placed.
e.        Generate warning if the shelf is 75% full.
f.        Store all the books information back into a file for future use.

这是我的没完成的code,因为真的不会了啊!
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
        char data,data1;
        int data2;
        struct node* link;
}NODE;

NODE* Insert_Book(NODE* bList , NODE* bPre , NODE* bCur , char bName,char bAuthor,int bPages){
       

        NODE* bNew = (NODE*)malloc(sizeof(NODE));
        bNew->data = bName;
        bNew->data1 = bAuthor;
        bNew->data2 = bPages;
        bNew->link = NULL;


        if(bPre == NULL){
                bNew->link = bList;
                bList = bNew;
        }
        else{
                bNew->link = bCur;
                bPre->link = bNew;
        }
        return bList;
}

int search_Book(NODE** pCur,NODE** pPre,NODE* pList,int book){
        *pCur = pList;
        *pPre = NULL;
        while(*pCur != NULL){
                if((*pCur)->data == book){
                        return 1; }
                *pPre = *pCur;
                *pCur = (*pCur)->link ;
        }return 0;
}

NODE* delete_Book(NODE* pList){
        NODE* pCur = pList;
        pList = pList->link;
        free(pCur);
        return pList;
}       

int main(){

        NODE* bList = NULL;
        NODE* bCur = NULL;
        NODE* bPre = NULL;
        char Name;
        char Author;
        int Pages;

        int choice;
        do{
        printf("*************************\n");
        printf("*\tMAIN MENU\t*\n");
        printf("*************************\n");
        printf("1.Insert a new book.\n");
        printf("2.Remove a book.\n");
        printf("3.Search for a book.\n");
        printf("4.List all the books.\n");
        printf("5.Exit the process.\n");
       
        do{
                printf("Enter your choice : ");
                scanf("%d",&choice);

                switch(choice){
                        case 1:
                                printf("Enter the book name : ");
                                scanf("%c",&Name);

                                printf("Enter the author name of the book : ");
                                fflush(stdin);
                                scanf("%c",&Author);

                                printf("Enter the pages of the book : ");
                                scanf("%d",&Pages);
                                bList = Insert_Book(bList,bPre,bCur,Name,Author,Pages);
                                bCur = bList;
                                while(bCur!=NULL){
                                        printf("%c %c %d\n",bCur->data,bCur->data1,bCur->data2);
                                        bCur = bCur->link;
                                }system("PAUSE");
                                break;
                        case 2:
                                break;
                        case 3:
                                break;
                        case 4:
                                break;
                        case 5:
                                system("cls");
                                printf("\nThank you\n");
                                system("PAUSE");
                                break;
                        default:
                                printf("\n\n\n>>>>>you must type in 1,2,3,4,or 5!<<<<<\n\n\n");
                                system("PAUSE");
                                break;
                        }
                }while(choice != 1 && 2 && choice != 3 && choice != 4 && choice != 5);
        }while(choice != 5);       
}
请帮帮我。。。
这是我的probem statement.
1.我要怎样将我所key in 的book name,author 换成string由function放进main里的case 1(Insert function)。
资料:Book Name ---string ; Author ---string ; Page ---int.

2.要怎样分3tier。

3怎样做ascending a-z。

4file《不懂啊~

5还有很多。。。

有好心人的话,求求你帮我解决吧!

[ 本帖最后由 凯茹 于 2009-7-26 09:04 PM 编辑 ]




收藏收藏0

9

主题

0

好友

4160

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 2009-7-26 08:59 PM |只看该作者
拜二要交了啊em0027 em0027


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

3#
发表于 2009-7-27 01:15 AM |只看该作者
臨時抱佛腳哦.... 我看這樣一來一回你肯定是來不及了


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

4#
发表于 2009-7-27 01:38 PM |只看该作者

回复 #1 凯茹 的帖子

Linked-list
C++ data structure 哦 。。。。
加油了你, C++ 很多限制, 不像其它语言那么自由, 对不起帮不到你了。


回复

使用道具 举报

9

主题

0

好友

4160

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

5#
发表于 2009-7-27 10:39 PM |只看该作者
改到拜五才交了~em0013 em0013


回复

使用道具 举报

17

主题

1

好友

1297

积分

黄金长老

Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8Rank: 8

6#
发表于 2010-3-5 02:57 AM |只看该作者
ascending就用sorting吧~
那一种sorting比较适合我不知道了


回复

使用道具 举报

13

主题

0

好友

2113

积分

白金长老

Rank: 10

7#
发表于 2010-3-7 12:51 AM |只看该作者
你的狗 漂亮!!!


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-25 09:28 PM , Processed in 0.118568 second(s), 28 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部