| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 525 人关注过本帖
标题:[求助]急如救火
取消只看楼主 加入收藏
wayne2121
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-7-1
收藏
 问题点数:0 回复次数:0 
[求助]急如救火

蓝色部分有错误,求助于高手,请帮忙更正
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MUNMAX 5
struct bookInfo{
int num;
char* name;
char* writer;
char* press;
float price;
};
struct bookType{
bookInfo book [MUNMAX];
int num;
};
void DisplayMenu();
int choiceItem();
void Init(struct bookType*);
void PrintInfo(struct bookType);
void Print_aInfo(struct bookType,int);
void Input_aInfo(struct bookInfo*);
void Input_allInfo(struct bookType*,int num);
int Search(struct bookType);
void Delete(struct bookType*);
void main()
{

struct bookType book;
int choice,index;

Init(&book);
do{
choice=choiceItem();
switch (choice){
case 0:printf("\nWelcome to\n");break;
case 1:Input_allInfo(&book,MUNMAX);break;
case 2:Input_allInfo(&book,1); break;
case 3:PrintInfo(book);break;
case 4:Init(&book);break;
case 5:if ((index=Search(book))!=-1)
Print_aInfo(book,index);
else printf("\n No eixst the book.");
break;
case 6:Delete(&book);break;
}
}while(choice);
}

void DisplayMenu()
{
printf("\n=========MENU =========");
printf("\n 1........Input_allInfo\n");
printf("\n 2........Input_allInfo\n");
printf("\n 3........PrintInfo\n");
printf("\n 4........Init\n");
printf("\n 5........Search\n");
printf("\n 6.........Delete\n");
printf("\n 0.........Exit System\n");
printf("\n Chioce:");
}

int choiceItem()
{
int choice;
do{
DisplayMenu();
scanf("%d",&choice);
}while(choice<0||choice>6);
return choice;
}

void Init(struct bookType* b)
{
b->num=0;
}

void Print_aInfo(struct bookType b,int index)
{
printf("\n%4d %-10s",b.book[index].num,b.book[index].name);

printf("%4s%4s%4f",b.book[index].writer,b.book[index].press,b.book[index].price);
}

void PrintInfo(struct bookType b)
{

if (b.num==0) {
printf("\nNo book.\n");
return;
}
for (int i=0;i<b.num;i++){
printf("\n%4d %-16s",b.book[i].num,b.book[i].name);
printf("%4s%4s%6.1f",b.book[i].writer,b.book[i].press,b.book[i].price);
}
}

void Input_aInfo(struct bookInfo* ab)
{

scanf("%d",&ab->num);
ab->name=(char*)malloc(30);
scanf("%s",ab->name);
ab->writer=(char*)malloc(30);
scanf("%s",&ab->writer);
ab->press=(char*)malloc(30);
scanf("%s",&ab->press);
scanf("%f",&ab->price);
}

void Input_allInfo(struct bookType* b,int num)
{
printf("\nInput %d book num\n",num);
for (int i=0;i<num;i++){
if (b->num==MUNMAX){
printf("\nOverflow.");
break;
}
Input_aInfo(&b->book[b->num++]);
}
}

int Search(struct bookType book)
{
int num;

printf("\nInput num:");
scanf("%d",&num);
for (int i=0;i<book.num;i++)
if (book.book[i].num==num)
return i;
return -1;
}

void Delete(struct bookType*)
{


}

搜索更多相关主题的帖子: 救火 
2006-07-01 22:51
快速回复:[求助]急如救火
数据加载中...
 
   



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

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