| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 984 人关注过本帖
标题:图书管理系统
只看楼主 加入收藏
虎子huzi
该用户已被删除
收藏
已结贴  问题点数:5 回复次数:5 
图书管理系统
提示: 作者被禁止或删除 内容自动屏蔽
搜索更多相关主题的帖子: 图书管理系统 
2010-05-09 18:03
草狼
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:577
专家分:1040
注 册:2010-4-6
收藏
得分:3 
void query2() /*按书名查询*/
{
char name[20],c;
int i;
system("cls");
printf("\n\t\tInput name:");
scanf("%s",name);
for(i=0;i<n;i++)
{
if (strcmp(books[i].name,name)==0)
{
    printf("\n\n\tnum:%d",books[i].num);
    printf("   name:%s",books[i].name);
    printf("   writer:%s",books[i].writer);
    printf("   inprice:%d",books[i].inprice);
    printf("   outprice:%d",books[i].outprice);
    printf("   date:%s",books[i].date);
    printf("   press:%s",books[i].press);
    printf("\n\n\tquery again(y/n):");
    getchar();
       if((c=getchar())=='y')
           {query2();}
       else
           {query();}
}
else
  {
    printf("\n\n\t\t\tIt no you query");
    printf("\n\n\t\t\t       anykey return query menu...");
    getch();
    query();
  }
}
}
void query1() /*按作者查询*/
{
char writer[10],c;
int i;
system("cls");
printf("\n\t\tInput writer:");
scanf("%s",writer);
for(i=0;i<n;i++)
{
if (strcmp(books[i].writer,writer)==0)
{
printf("\n\n\tnum:%d",books[i].num);
    printf("   name:%s",books[i].name);
    printf("   writer:%s",books[i].writer);
    printf("   inprice:%d",books[i].inprice);
    printf("   outprice:%d",books[i].outprice);
    printf("   date:%s",books[i].date);
    printf("   press:%s",books[i].press);
    printf("\n\n\tquery again(y/n):");
    getchar();
       if((c=getchar())=='y')
           {query1();}
       else
           {query();}
}
else
  { system("cls");
    printf("\n\n\t\t\tIt no you query");
    printf("\n\n\t\t\t       anykey return query menu...");
    getch();
    query();
  }
}
}


这样改下不知道可不可以了啊
2010-05-09 18:21
虎子huzi
该用户已被删除
收藏
得分:0 
回复 2楼 草狼
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-10 13:52
宋文鸿
Rank: 1
等 级:新手上路
帖 子:5
专家分:2
注 册:2010-5-24
收藏
得分:0 
谁有关于这个的论文么?
2010-06-22 19:46
jianjunwang
Rank: 1
等 级:新手上路
帖 子:3
专家分:7
注 册:2010-6-22
收藏
得分:0 
#include "stdio.h"
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#define N 100;/*图书总量*/
struct book
{
    int num;/*图书号*/
    char name[20];/*图书名*/
    char writer[20];/*图书作者*/
    int inprice;/*进书家格*/
    int outprice;/*销售价格*/
    char date[20]; /*生产日期*/
    char press[20];/*出版社*/
}books[100];
struct book*p;
void print_1();/*主界面调用*/
void record(); /*图书信息录入*/
void print();    /*显示图书信息*/
void update();  /*图书信息更新*/
void query();   /*图书信息查询*/
void statistics();  /*图书信息统计*/
void ranking(); /*图书信息排行*/
void exit();
void query1();
void query2();
/*显示,更新调用函数*/
void Changes();
void Add();
void Rmove();
void num();
void writer();
void name();
void inprice();
void outprice();
void date();
void press();

/*结束*/
int n=0;
main()/*主函数*/
{
    printf("\n\n");
    printf("         **********welcome to Library Management System******\n\n\n\n");
    printf("                     *******please put any key*******");
    getch();
    //clrscr();
    system("CLS");
    print_1();
    //clrscr();
    system("CLS");
}
void print_1()/*主界面*/
{
    char i;
    system("cls");
    printf("        *******Library Management System*******\n\n");
    printf("        *    1.Record Book Information        *\n\n");
    printf("        *    2.Print Book Information         *\n\n");
    printf("        *    3.Update Book Information        *\n\n");
    printf("        *    4.Query Book Information         *\n\n");
    printf("        *    5.Statistics Book Information    *\n\n");
    printf("        *    6.Book Ranking Information       *\n\n");
    printf("        *    0.Exit System                    *\n");
    printf("        **************************************\n\n ");
    printf("        choose(0-6):");
    while(1)
    {   
        scanf("%c",&i);
        printf("        你选择了:%c\n:",i);
        if(i>='0' && i<='6')
        {   
            switch(i)
            {
                case '1': record();break;
                case '2': print(); break;
                case '3': update();break;
                case '4': query();break;
                case '5': statistics();break;
                case '6': ranking();break;
                case '0': exit(0);
            }
            getch();
        }
        else  printf("       error,please enter (0-6)!\n");
    }
}

    /*我的页面*/
void record()/*图书信息录入*/
{
    int j;
    system("cls");
    printf("\n\t\tadd new book\n");

    printf("\n\t\tbook num:");
    scanf("%d",&books[n].num);

    printf("\n\t\tbook name:");
    scanf("%s",&books[n].name);

    printf("\n\t\tbook writer:");
    scanf("%s",&books[n].writer);

    printf("\n\t\tinto the book price:");
    scanf("%d",&books[n].inprice);

    printf("\n\t\tout price:");
    scanf("%d",&books[n].outprice);

    printf("\n\t\tdate:");
    scanf("%s",&books[n].date);

    printf("\n\t\tpress:");
    scanf("%s",&books[n].press);
    n++;
    printf("\n\t\tcontinue?(y/n)");
    getchar();
    if (getchar()=='y')
        record();
    else
        print_1();
   return;
}
void  print() /*显示图书信息*/
{
    int i;
    system("cls");

    if(n>0)
    {
        printf("\t\t\t    Gong you %d tiao ji lu\n",n);
        printf("\n \t\t----------------------------------------------");
        for(i=0;i<n;i++)
        {
            printf("\n\n\t\t\t\tDi %d Tiao Ji Lu",i+1);
            printf("\n\n\tnum:%d",books[i].num);
            printf("   name:%s",books[i].name);
            printf("   writer:%s",books[i].writer);
            printf("   inprice:%d",books[i].inprice);
            printf("   outprice:%d",books[i].outprice);
            printf("   date:%s",books[i].date);
            printf("   press:%s",books[i].press);
        }         
        printf("\n \t\t----------------------------------------------\n");
        printf("\n \t\tInput anykey to main");
        getch();
        print_1();
    }
    else
        printf("\t\t\t\tit is nothing!\n\n\t\t\t    Input anykey to main");
    getch();
    print_1();
}

void update()  /*图书信息更新*/
{   
    int a;
    system("cls");
    printf("\n\t\t\t****Update Book Information****\n\n");
    printf("\n\t\t\t    1.Add Book Information\n");
    printf("\n\t\t\t    2.Rmove Book Information\n");
    printf("\n\t\t\t    3.Changes Book Information\n");
    printf("\n\t\t\t    0.Back to main menu\n");
    printf("\n\t\tInput you choose:");
    scanf("%d",&a);
    switch(a)
    {
        case 0:print_1();
        case 1:Add();break;
        case 2:Rmove();break;
        case 3:Changes();break;
    }
    getch();
}
/*--------------图书更新内容------------------------*/

void Changes() /*更改页面*/
{
    int a;
    system("cls");
    printf("\n\t\t\t****Changes Book Information****\n\n");
    printf("\n\t\t\t    1.Changes num\n");
    printf("\n\t\t\t    2.Changes name\n");
    printf("\n\t\t\t    3.Changes writer\n");
    printf("\n\t\t\t    4.Changes inprice\n");
    printf("\n\t\t\t    5.Changes outprice\n");
    printf("\n\t\t\t    6.Changes date\n");
    printf("\n\t\t\t    7.Changes press\n");
    printf("\n\t\t\t    0.Back to Changes menu\n");
    printf("\n\t\tInput you choose:");
    scanf("%d",&a);
    switch(a)
    {
        case 1: num();break;
        case 2: name(); break;
        case 3: writer();break;
        case 4: inprice();break;
        case 5: outprice();break;
        case 6: date();break;
        case 7: press();break;
        case 0: update();break;
    }
    getch();
}

   /*-------------更改内容-----------------*/

void num() /*更改图书编号*/
{   
    int i;
    char str[20];
    printf("Input You Changes num's name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n\t\t输入编号:");
            fflush(stdin);
            scanf("%d",&books[i].num);

            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\t任意键进入主界面");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}

void writer()/*更改图书作者*/
{
    int i;
    char str[20];
    printf("Input You Changes writer's name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n输入作者:");
            fflush(stdin);
            scanf("%s",&books[i].writer);

            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\tren yi jian jin ru zhu ye mian");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}

void name()/*更改图书名字*/
{
    int i;
    char str[20];
    printf("Input You Changes name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {        
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n输入名字:");
            fflush(stdin);
            scanf("%s",&books[i].name);

            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\tren yi jian jin ru zhu ye mian");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}

void inprice() /*更改图书进价*/
{
    int i;
    char str[20];
    printf("Input You Changes inprice's name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n输入入厂价:");
            fflush(stdin);
            scanf("%d",&books[i].inprice);
            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\tren yi jian jin ru zhu ye mian");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}

void outprice()/*更改图书卖价*/
{   
    int i;
    char str[20];
    printf("Input You Changes outprice's name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n输入卖价:");
            fflush(stdin);
            scanf("%d",&books[i].outprice);

            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\tren yi jian jin ru zhu ye mian");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}

void date() /*更改图书日期*/
{
    int i;
    char str[20];
    printf("Input You Changes date's name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n输入日期");
            fflush(stdin);
            scanf("%s",&books[i].date);


            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\tren yi jian jin ru zhu ye mian");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}
void press() /*更改图书出版社*/
{   
    int i;
    char str[20];
    printf("Input You Changes press's name:");
    fflush(stdin);
    gets(str);
    for(i=0;i<n;i++)
    {   
        if(!strcmp(books[i].name,str))
        {
            system("cls");
            printf("\n\t\t输入新插入图书信息\n");
            printf("\n输入出版社");
            fflush(stdin);
            scanf("%s",&books[i].press);

            printf("\n\n");
            printf("\n\t\t\t修改完毕");
            printf("\n\t\t\tren yi jian jin ru zhu ye mian");
            getch();
            print_1();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\t\t\t\tNo this name");
            printf("\n\t\t\t   anykey renturn Changes");
            getch();
            system("cls");
            Changes();
        }
    }
}
  /*-------------更改结束----------------*/
void Add() /*添加新纪录*/
{
    int j;
    printf("\n\t\tadd new book\n");

    printf("\n\t\tbook num:");
    scanf("%d",&books[n].num);

    printf("\n\t\tbook name:");
    scanf("%s",&books[n].name);

    printf("\n\t\tbook writer:");
    scanf("%s",&books[n].writer);

    printf("\n\t\tinto the book price:");
    scanf("%d",&books[n].inprice);

    printf("\n\t\tout price:");
    scanf("%d",&books[n].outprice);

    printf("\n\t\tdate:");
    scanf("%s",&books[n].date);

    printf("\n\t\tpress:");
    scanf("%s",&books[n].press);
    n++;
    printf("\n\t\tcontinue?(y/n)");
    getchar();
    if (getchar()=='y')
        Add();
    else
        update();
}

void Rmove() /*删除信息*/
{
    int a=0;
    int i,j;
    int deletemark=0;
    char name[20];

    printf("\n\t\t请输入要删除的书名:");
    scanf("%s",name);
    for (i=a;i<n;i++)
    {
        if (strcmp(books[i].name,name)==0)
        {
            printf("\n\t\t这是你要删除的信息?");
            printf("\n\n\tnum:%d",books[i].num);
            printf("  name:%s",books[i].name);
            printf("  writer:%s",books[i].writer);
            printf("   inprice:%d",books[i].inprice);
            printf("   outprice:%d",books[i].outprice);
            printf("   date:%s",books[i].date);
            printf("   press:%s",books[i].press);
            printf("\n\n\t\t是否删除?(y/n)");
            getchar();
            if (getchar()=='y')
            {
                for (j=i;j<n-1;j++) /*纪录移动,从stud数组中删除之*/
                    books[j]=books[j+1];
                n--;
                deletemark++;
                printf("\n\t\t删除成功\n");
                printf("\n\t\t是否继续?(y/n)");
                getchar();
                if (getchar()=='y')
                    Rmove();
                else
                    update();
            }
            else
                update();
        }   
    }
    if (deletemark==0)
    {   
        system("cls");
        printf("\t\t\t\tit is nothing!\n\n\t\t\t    Input anykey to update...\n");
        getch();
        update();
    }
}

/*--------------更新结束-----------------------*/

/*结束*/
void query() /*图书信息查询*/
{   
    int i;
    if(n>0)
    {
        system("cls");
        printf("                **********query book information************\n") ;
        printf("\n                         1.books by writer query\n");
        printf("\n                         2.books by book name\n");
        printf("\n                         0.back to main menu\n");
        printf("\n\n         please select (0-2):");
        scanf("%d",&i);
        switch(i)
        {
            case 1:query1();break;
            case 2:query2();break;
            case 0:print_1();break;
        }
    }
    else
    {
        system("cls");
        printf("\n\t\t\t       It Nothing");
        printf("\n\n\t\t\tanykey return to main menu...\n");
        getch();
        print_1();
    }
}

void query2() /*按书名查询*/
{
    char name[20];
    int i;
    system("cls");
    printf("\n\t\tInput name:");
    scanf("%s",name);
    for(i=0;i<n;i++)
    {
        if (strcmp(books[i].name,name)==0)
        {
            printf("\n\n\tnum:%d",books[i].num);
            printf("   name:%s",books[i].name);
            printf("   writer:%s",books[i].writer);
            printf("   inprice:%d",books[i].inprice);
            printf("   outprice:%d",books[i].outprice);
            printf("   date:%s",books[i].date);
            printf("   press:%s",books[i].press);
            printf("\n\n\tquery again(y/n):");
            getchar();
            if(getchar()=='y')
                query2();
            else
                query();
        }
        else if(i == n-1)
        {
            printf("\n\n\t\t\tIt no you query");
            printf("\n\n\t\t\t       anykey return query menu...");
            getch();
            query();
        }
    }
}
void query1() /*按作者查询*/
{
    char writer[10];
    int i;
    system("cls");
    printf("\n\t\tInput writer:");
    scanf("%s",writer);
    for(i=0;i<n;i++)
    {
        if (strcmp(books[i].writer,writer)==0)
        {
            printf("\n\n\tnum:%d",books[i].num);
            printf("   name:%s",books[i].name);
            printf("   writer:%s",books[i].writer);
            printf("   inprice:%d",books[i].inprice);
            printf("   outprice:%d",books[i].outprice);
            printf("   date:%s",books[i].date);
            printf("   press:%s",books[i].press);
            printf("\n\n\tquery again(y/n):");
            getchar();
            if(getchar()=='y')
                query1();
            else
                query();
        }
        else if(i == n-1)
        {
            system("cls");
            printf("\n\n\t\t\tIt no you query");
            printf("\n\n\t\t\t       anykey return query menu...");
            getch();
            query();
        }
    }
}

void  statistics()  /*图书信息统计*/
{
    char name[10];
    int i,t;
    if(n>0)
    {
        system("cls");
        printf("\n\t\tInput name:");
        scanf("%s",name);
        for(i=0;i<n;i++)
        {
            if (strcmp(books[i].name,name)==0)
            {
                printf("\n\n\tnum:%d",books[i].num);
                printf("   name:%s",books[i].name);
                printf("   writer:%s",books[i].writer);
                printf("   inprice:%d",books[i].inprice);
                printf("   outprice:%d",books[i].outprice);
                printf("   date:%s",books[i].date);
                printf("   press:%s",books[i].press);
                printf("\n\n\t\tanykey return main...");
                getch();
                print_1();
            }
            else if(i == n-1)
            {    system("cls");
                printf("\n\n\t\t\tIt no you query");
                printf("\n\n\t\t\t       anykey return query menu...");
                getch();
                print_1();
            }
        }
    }
    else
    {
       system("cls");
       printf("\n\t\t\t      It Nothing");
       printf("\n\t\t\tanykey return to main...\n");
       getch();
       print_1();
    }
}


void  ranking() /*图书信息排行*/
{   
    struct book t;
    int i,j;
    //clrscr();
    system("CLS");
    for(i=1;i<n;i++)
    {
        for(j=1;j<=n-i;j++)
        {
            if(books[j-1].num<books[j].num)
            {
                t=books[j];
                books[j]=books[j-1];
                books[j-1]=t;
            }
        }
    }
    printf("\t\t\t    共有 %d 调记录\n",n);
    printf("\n \t\t----------------------------------------------");
    for(i=0;i<n;i++)
    {
        printf("\n\n\t\t\t\tdi %d 调记录",i+1);
        printf("\n\n\tnum:%d",books[i].num);
        printf("  name:%s",books[i].name);
        printf("  writer:%s",books[i].writer);
        printf("   inprice:%d",books[i].inprice);
        printf("   outprice:%d",books[i].outprice);
        printf("   date:%s",books[i].date);
        printf("   press:%s",books[i].press);
    }         
    printf("\n \t\t----------------------------------------------\n");
    printf("\n \t\tInput anykey to main");
    getch();
    print_1();
}


这个应该好用,我试过了
2010-06-23 11:02
archenemy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-6-23
收藏
得分:0 
我有一个跟这类似的题目,求助高手
题目要求:用C语言编写一个简单的图书管理程序,该程序实现增加、删除、查找、显示相关图书信息记录的功能,并实现图书信息保存到文件,实现文件读写功能。1。以结构体方式实现图书信息记录,每条记录应包括图书编号,书名,作者,出版社,出版年月,定价,备注;2。以链表方式实现图书信息记录的添加,删除,查找,显示;3。将完整的图书信息记录表存储到文件,并能读取文件中的内容。
2010-06-23 18:53
快速回复:图书管理系统
数据加载中...
 
   



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

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