计算机程序设计基础(C语言)
课程设计说明书
设计题目:       仓库物料信息管理系统                       
班级:             
姓名:             
学号:             
202012
设计任务书
一、需求分析
设计题目:
仓库物料信息管理系统
记录每种物料的名称、编号、数量、价格、产地等信息;
能够对系统中各种物料进行检索,查相关信息;
能够对各种物料对物料进行信息修改。
能够汇总某一段时间内的物料使用情况,统计相关信息。
将物料按数量从少到多排序。
二、概要设计
1.系统总体设计框架
1)登记物料信息,名称,数量,编号,价格,产地时间。
2)浏览物料信息
3)查询物料信息,依据物料的名称进行查。
4)修改物料信息
5)删除物料信息,依据物料的名称进行删除。
6)物料信息排序,将物料按数量从少到多进行排序。
7)打开文件
8)保存文件
9)退出程序
2.设计思路
登记
浏览
仓库物料信息管理系统
修改
删除
排序
三、详细设计
主要功能模块的算法。
1.数据类型设计
struct item      //声明结构体类型struct something
{
        char name[20];    //物品名称
        int num;    //编号
        int amount;  //数量
        float price;        //价格
        char address[20];    //产地
        char time[10];          //时间
};
2.删除方式---指定位置删除。(依靠姓名删除)
void  delete_1(struct node* headnode, char*posname)
{
    struct node* posfrontnode = headnode;
    struct node* posnode = headnode->next;
    //指定位置。
    while (posnode != NULL && strcmp(posnode->data.name,posname))
    {
        posfrontnode = posnode;
        posnode = posfrontnode->next;
    }
    if (posnode == NULL)
    {
        return;
    }
    //不为空------到就可以删除。
    posfrontnode->next = posnode->next;
    free(posnode);
    posnode = NULL;
3.查方式---依靠姓名。
struct node* searchinfobyname(struct node* headnode, char*posname)
{
    struct node* p = headnode->next;
    while (p != NULL && strcmp(p->data.name,posname))
    {
        p = p->next;
    }
    return p;
4.打印方式---输出
void print_1(struct c语言中structnode* headnode)
{
    struct node* p = headnode->next;
    //信息展示的表头
    printf("名称\t\t编号\t\t数量\t\t价格\t\t产地\t\t时间\n");
    while (p != NULL)
    {
        printf("%s\t\t%d\t\t%d\t\t%-3.2f\t\t%s\t\t%s\n", p->data.name, p->data.num,
            p->data.amount, p->data.price, p->data.address, p->data.time);
        p = p->next;
    }
    printf("\n");
}
5.依据数量从少到多排序。
void bubblesort(struct node* headnode)
{
    struct node* firstnode = headnode->next;
    struct node* secondnode = headnode;
    while (firstnode != NULL)
    {
        while (firstnode->next != NULL)
        {
            if (firstnode->data.num > firstnode->next->data.num)
            {
                struct item tempdata = firstnode->data;    //交换节结点数据
                firstnode->data = firstnode->next->data;
                firstnode->next->data = tempdata;
            }
            firstnode = firstnode->next;
        }
        firstnode = secondnode->next;
        secondnode = firstnode;
    }
}
6.把链表中的内容写到文件里面
void  saveinfofile(struct node* headnode, char* filename)
{
    FILE* fp = fopen(filename, "w");
    struct node* p = headnode->next;
    while (p != NULL)                    //fprintf
    {
        fprintf(fp, "%s\t\t%d\t\t%d\t\t%f\t\t%s\t\t%s\n", p->data.name,
            p->data.num, p->data.amount, p->data.price, p->data.address, p->data.time);
        p = p->next;