cpp大作业(班级通讯录和商品管理系统)

cpp大作业(班级通讯录和商品管理系统)

c++课设大作业
1.班级通讯录
该代码必须运行在devc++里面,否则会报错和乱码

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#include <iostream>
#include <stdlib.h>
typedef struct student     //定义结构体
{
    char name[20];    //姓名
    char num[15];      //学号
    char clas[10];     //班级
    char sex[10];     //性别
    char address[20];    //通讯录地址
    char political[10];    //政治面貌
    char phone[15];      //手机号
    char familynum[15];  //家庭电话
    char QQmail[15];         //电子邮件
    char youbian[20];     //邮编
    struct student* next;  //结构体指针
}stu;
stu* head;

void print()    //主菜单
{
    system("cls");
    printf("\n\n\n");
    printf("      ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n");
    printf("      ***********************************************************\n");
    printf("      \t\t\t班级通讯录管理系统\n");
    printf("\n");
    printf("      \t\t1. 输入数据");
    printf("\t\t2. 显示数据\n");
    printf("      \t\t3. 插入数据");
    printf("\t\t4. 删除数据\n");
    printf("      \t\t5. 查看数据");
    printf("\t\t6. 修改数据\n");
    printf("      \t\t7. 保存数据");
    printf("\t\t8. 返回主菜单\n");
    printf("      ***********************************************************\n");
    printf("      ~~~~~退~~~~~~~~~~出~~~~~~~~~~请~~~~~~~~~~按~~~~~~~~~~9~~~~~\n");
    printf("      -----------------------------------------------------------\n\n");
}


void input(stu* p1)    //输入相关数据
{
    printf("姓名:");
    scanf("%s", &p1->name);
    printf("学号:");
    scanf("%s", &p1->num);
    printf("班级:");
    scanf("%s", &p1->clas);
    printf("性别:");
    scanf("%s", &p1->sex);
    printf("通讯录地址:");
    scanf("%s", &p1->address);
    printf("政治面貌:");
    scanf("%s", &p1->political);
    printf("手机号:");
    scanf("%s", &p1->phone);
    printf("家庭电话:");
    scanf("%s", &p1->familynum);
    printf("电子邮件:");
    scanf("%s", &p1->QQmail);
    printf("邮编:");
    scanf("%s", &p1->youbian);
}

//printf("姓名:%s\n", p2->name);
//printf("学号:%s\t", p2->num);
//printf("班级:%s\t", p2->clas);
//printf("性别:%s\t", p2->sex);
//printf("通讯录地址:%s\t", p2->address);
//printf("政治面貌:%s\t", p2->political);
//printf("手机号:%s\t", p2->phone);
//printf("家庭电话:%s\t", p2->familynum);
//printf("电子邮件:%s\t", p2->QQmail);
//printf("邮编:%s\n", p2->youbian);
stu* inputdata()     //数据输入的函数
{
    stu* p1, * p2;
    int i = 1;
    p1 = (stu*)malloc(sizeof(stu));
    if (p1 != NULL)
    {
        head = p1;
        printf("\n\t\t\t☆☆☆输入数据☆☆☆\n");
        printf("------------------------------------------------------------------\n");
        printf("在姓名处输入“ok”代表输入数据结束\n");
        while (i)
        {
            printf("姓名:");
            scanf("%s", &p1->name);
            if (strcmp(p1->name, "ok") == 0)
            {
                printf("\n输入完毕!\n");
                printf("========================================================================\n");
                i = 0;
                p2->next = NULL;
                free(p1);
                p1 = p2;
            }
            else
            {
                printf("学号:");
                scanf("%s", &p1->num);
                printf("班级:");
                scanf("%s", &p1->clas);
                printf("性别:");
                scanf("%s", &p1->sex);
                printf("通讯录地址:");
                scanf("%s", &p1->address);
                printf("政治面貌:");
                scanf("%s", &p1->political);
                printf("手机号:");
                scanf("%s", &p1->phone);
                printf("家庭电话:");
                scanf("%s", &p1->familynum);
                printf("电子邮件:");
                scanf("%s", &p1->QQmail);
                printf("邮编:");
                scanf("%s", &p1->youbian);
                
                printf("=====================================\n");
                p2 = p1;
                p1 = (stu*)malloc(sizeof(stu));
                if (p1 != NULL)
                {
                    p2->next = p1;
                }
            }
        }
        return(p1->next);
    }
}


stu* lookdata(stu* p1)     //查看数据的函数
{
    printf("\n\t\t\t☆☆☆显示数据☆☆☆\n");
    printf("----------------------------------------------------------------------\n");
    while (p1 != NULL)
    {
        printf("姓名:%s\n", p1->name);
        printf("班级:%s\t", p1->clas);
        printf("学号:%s\t", p1->num);
        printf("性别:%s\t", p1->sex);
        printf("通讯录地址:%s\t", p1->address);
        printf("政治面貌:%s\t", p1->political);
        printf("手机号:%s\t", p1->phone);
        printf("家庭电话:%s\t", p1->familynum);
        printf("电子邮件:%s\t", p1->QQmail);
        printf("邮编:%s\t", p1->youbian);
        printf("======================================================================\n");
        p1 = p1->next;
    }
    return p1;
} 


void insert()      //插入数据
{
    int i;
    char named[20];
    stu* p1, * p2, * p3;
    p1 = head;
    p3 = (stu*)malloc(sizeof(stu));
    p3->next = NULL;
    printf("\n\t\t\t☆☆☆插入数据☆☆☆\n");
    printf("----------------------------------------------------------------------\n");
    printf("请输入插入者的资料:\n");
    input(p3);
    printf("\n插入选项\n");
    printf("1.首位置插入\t2.尾位置插入\t3.前插\n");
    printf("请输入你的选择:");
    scanf("%d", &i);
    switch (i)
    {
    case 1:p3->next = p1;
        head = p3;
        break;
    case 2:while (p1->next != NULL)
    {
        p2 = p1;
        p1 = p1->next;
    }
          p1->next = p3;
          break;
    case 3:printf("请输入姓名(前插):");
        scanf("%s", named);
        while (strcmp(named, p1->name) != 0)
        {
            p2 = p1;
            p1 = p1->next;
        }
        p2->next = p3;
        p3->next = p1;
        break;
    }
    printf("插入成功!\n");
    printf("======================================================================\n");
    return;
}

void deleted()          //删除数据
{
    stu* p1, * p2;
    char Name[20];  //想要删除的人的姓名
    printf("\n\t\t\t☆☆☆删除数据☆☆☆\n");
    printf("----------------------------------------------------------------------\n");
    printf("请输入要删除的姓名:");
    scanf("%s", Name);
    p1 = head;
    if (head == NULL)
    {
        printf("内存没有存储任何数据!\n");
        printf("======================================================================\n");
        return;
    }
    if (strcmp(Name, p1->name) == 0)
    {
        head = p1->next;
        printf("删除成功!\n");
        printf("======================================================================\n");
        return;
    }
    while (p1 != NULL && (strcmp(Name, p1->name) != 0))
    {
        p2 = p1;
        p1 = p1->next;
    }
    if (p1 == NULL)
    {
        printf("此人不存在!\n");
        printf("======================================================================\n");
        return;
    }
    if (p1->next != NULL)
    {
        p1 = p1->next;
        p2->next = p1;
        printf("删除成功!\n");
        printf("======================================================================\n");
        return;
    }
    else
    {
        p2->next = NULL;
        printf("删除成功!\n");
        printf("======================================================================\n");
        return;
    }
}


void find(stu* p2)        //通过姓名查找查看数据的函数
{
    char name[20];
    int b = 0;
    printf("\n\t\t\t☆☆☆查看数据☆☆☆\n");
    printf("----------------------------------------------------------------------\n");
    printf("请输入您想查找人的姓名:");
    scanf("%s", name);
    while (p2 != NULL)
    {
        if (strcmp(name, p2->name) == 0)
        {
            printf("你要找到的数据\n");
            printf("姓名:%s\n", p2->name);
            printf("学号:%s\t", p2->num);
            printf("班级:%s\t", p2->clas);
            printf("性别:%s\t", p2->sex);
            printf("通讯录地址:%s\t", p2->address);
            printf("政治面貌:%s\t", p2->political);
            printf("手机号:%s\t", p2->phone);
            printf("家庭电话:%s\t", p2->familynum);
            printf("电子邮件:%s\t", p2->QQmail);
            printf("邮编:%s\n", p2->youbian);
            printf("======================================================================\n");
            b = 1;
        }
        p2 = p2->next;
    }
    if (b == 0)
    {
        printf("\n您要查找的人不存在!\n");
    }
}


void update(stu* p2)   //通过姓名查找修改数据
{
    char name[20];
    int b = 0, i;
    printf("\n\t\t\t☆☆☆修改数据☆☆☆\n");
    printf("----------------------------------------------------------------------\n");
    printf("请输入将要修改人的姓名:");
    scanf("%s", name);
    while (p2 != NULL)
    {
        if (strcmp(name, p2->name) == 0)
        {
            printf("该同学的基本信息\n");
            printf("姓名:%s\n", p2->name);
            printf("学号:%s\t", p2->num);
            printf("班级:%s\t", p2->clas);
            printf("性别:%s\t", p2->sex);
            printf("通讯录地址:%s\t", p2->address);
            printf("政治面貌:%s\t", p2->political);
            printf("手机号:%s\t", p2->phone);
            printf("家庭电话:%s\t", p2->familynum);
            printf("电子邮件:%s\t", p2->QQmail);
            printf("邮编:%s\n", p2->youbian);
            printf("\n请选择要修改的信息\n");
            printf("\t1.姓名\t2.学号\t3.班级\t4.性别\n\t5.通讯录地址\t6.政治面貌\t7.手机号\t8.家庭电话\n\t9.电子邮件\t10.邮编\t");
            printf("\n您的选择是(1~8):");
            scanf("%d", &i);
            printf("请输入修改之后的内容\n");
            switch (i)
            {
            case 1:printf("姓名:");
                scanf("%s", &p2->name);
                break;
            case 2:printf("学号:");
                scanf("%s", &p2->num);
                break;
            case 3:printf("班级:");
                scanf("%s", &p2->clas);
                break;
            case 4:printf("性别:");
                scanf("%s", &p2->sex);
                break;
            case 5:printf("通讯录地址:");
                scanf("%s", &p2->address);
                break;
            case 6:printf("政治面貌:");
                scanf("%s", &p2->political);
                break;
            case 7:printf("手机号");
                scanf("%s", &p2->phone);
                break;
            case 8:printf("家庭电话");
                scanf("%d", &p2->familynum);
                break;
            case 9:printf("电子邮件");
                scanf("%d", &p2->QQmail);
                break;
            case 10:printf("邮编");
                scanf("%d", &p2->youbian);
                break;
            }
            printf("\n修改成功!\n");
            printf("=========================================================================\n");
            b = 1;
        }
        p2 = p2->next;
    }
    if (b == 0)
    {
        printf("没有找到该人的资料!\n");
    }
}


void save(stu* p2)   //保存数据
{
    FILE* fp;
    char file[15];
    printf("\n\t\t\t☆☆☆保存数据☆☆☆\n");
    printf("----------------------------------------------------------------------\n");
    printf("输入文件名:");
    scanf("%s", file);
    if ((fp = fopen(file, "w")) == NULL)
    {
        printf("cannot open this file\n");
        exit(0);
    }
    fprintf(fp, "姓名\t学号\t班级\t性别\t通讯录地址\t政治面貌\t手机号\t家庭电话\t电子邮件\t邮编\t\n");
    while (p2 != NULL)
    {
        fprintf(fp, "%s\t", p2->name);
        fprintf(fp, "%s\t", p2->num);
        fprintf(fp, "%s\t", p2->clas);
        fprintf(fp, "%s\t", p2->sex);
        fprintf(fp, "%s\t", p2->address);
        fprintf(fp, "%s\t", p2->political);
        fprintf(fp, "%s\t", p2->phone);
        fprintf(fp, "%s\t", p2->familynum);
        fprintf(fp, "%s\n", p2->QQmail);
        fprintf(fp, "%s\t", p2->youbian);
        p2 = p2->next;
    }
    printf("\n保存成!\n");
    printf("======================================================================\n");
    fclose(fp);
}


void screen()
{
    int i;
    char s[251] = { "欢迎使用班级通讯录管理系统,\n\n\t\t\t本系统用于通讯录管理----排序,打印\n\n\n\t\tWelcome to use class address book\n\n\t\t management system,sorting,printing" };

    printf("\n================================================================================\n");
    printf("\n\n\n\t\t\t");
    for (i = 0; s[i] != NULL; i++)
    {
        Sleep(30);
        printf("%c", s[i]);
    }
    printf("\n\n\n\n\n\n\n\n\t\t ~ Hi~ o(* ̄▽ ̄*)ブ~ ~ ~祝您使用愉快~ ~\n");
    printf("================================================================================\n");

}


int main(void)
{
    int i;
//    system("color 01");
	system("color F0");
    screen();
    Sleep(3000);
    print();
    while (1)
    {
        printf("请输入你的选择(1~9):");
    loop:scanf("%d", &i);
        if (i < 1 || i>9)
        {
            printf("输入有误,请在1~9中进行选择:");
            goto loop;
        }
        switch (i)
        {
        case 1:
            inputdata();
            break;
        case 2:
            lookdata(head);
            break;
        case 3:
            insert();
            break;
        case 4:
            deleted();
            break;
        case 5:
            find(head);
            break;
        case 6:
            update(head);
            break;
        case 7:
            save(head);
            break;
        case 8:
            print();
            break;
        case 9:
            exit(1);
            break;
        }
    }
    return 0;
}

2.商品管理系统
该代码必须运行在vs2019里面,否则会乱码和报错

//商品类型 供应商编号、供应商名称、联系电话
#include<iostream>          //头文件的使用很关键 
#include<stdlib.h>
#include <fstream> 
#include <algorithm>
#include<iomanip>
using namespace std;

//需要使用的全局变量 
int flag1 = 0, flag2 = 0, flag3 = 0;         //flag要记得赋初值为0 
int t = 0, i, j, m, n = 0, z, s, b;
string cx1, cx2, cx3, cx4, n1, n2;
ofstream out;                       //定义一个全局输出流变量out

struct commidity
{
    string name1;                   //商品名称
    string num;                     //商品编号 
    string name2;                   //供应商名称
    string num2;                    //供应商编号
    string phone;                   //联系电话
    string type;                    //商品类型 
    string day;                     //生产日期 
    double price;                   //商品价格 
}a[1000];
 
void main_menu();                   //定义一个主菜单函数 

int main()                          //主函数 
{
    main_menu();                    //进入欢迎界面 
    return 0;
}

void Input()                       //定义一个录入信息的函数 
{
    cout << "\n---------------------------------------------------请录入商品信息-------------------------------------------------------\n\n";
    cout << "请输入您要录入的商品数量:";
    cin >> n;
    cout << endl;
    cout << "请依次输入“商品名称”、“商品编号”、“供应商名称”、“供应商编号”、“联系电话”、“商品类型”、“生产日期”、“商品价格”\n\n";
    for (s = 0; s < n; s++)
    {
        cout << "请输入商品名称:" << endl;                                                    //输入商品名称
        cin >> a[s].name1;
        cout << "请输入商品编号:" << endl;                                                    //输入商品编号
        cin >> a[s].num;
        cout << "请输入商品供应商名称:" << endl;                                                //输入商品供应商名称 
        cin >> a[s].name2;
        cout << "请输入商品供应商编号:" << endl;                                                //输入商品供应商编号
        cin >> a[s].num2;
        cout << "请输入商品供应商联系电话:" << endl;                                                //输入商品供应商电话
        cin >> a[s].phone;
        cout << "请输入商品类型:" << endl;                                                    //输入型号
        cin >> a[s].type;
        cout << "请输入商品生产日期:(格式为:年/月/日    例:2020/03/23)" << endl;            //输入生产日期
        cin >> a[s].day;
        cout << "请输入商品价格:" << endl;                                                    //输入商品价格
        cin >> a[s].price;
    }
    ofstream out;
    out.open("商品管理.txt");                         //打开文件,将信息导入文件 
    for (s = 0; s < n; s++)
        out << setw(10) << a[s].name1 << setw(10) << a[s].num << setw(10) << a[s].name2 << setw(10) << a[s].num2 << setw(10) << a[s].phone << setw(10) << a[s].type << setw(10) << a[s].day << setw(10) << a[s].price << endl;    //将信息导入文件 
    out.close();                                      //关闭文件  
    cout << "\n录入成功,请在对应文件夹中查看!" << endl;
    cout << endl;
}

void Browse()                         //定义一个浏览信息的函数 
{
    cout << "\n----------------------------------------------------浏览商品信息--------------------------------------------------------\n\n";
    if (n == 0)
        cout << "系统当前尚未录入商品信息!\n\n";
    else
    {
        for (i = 0; i < n; i++)
        {
            cout << "商品名称" << i + 1 << ": " << a[i].name1 << endl;
            cout << "商品编号:" << a[i].num << endl;
            cout << "供应商名称:" << a[i].name2 << endl;
            cout << "供应商编号:" << a[i].num2 << endl;
            cout << "供应商联系电话:" << a[i].phone << endl;
            cout << "商品类型:" << a[i].type << endl;
            cout << "生产日期:" << a[i].day << endl;
            cout << "商品价格:" << a[i].price << endl;
            cout << endl;
        }
    }
}

void Modify()                        //定义一个修改信息的函数 
{
    cout << "\n----------------------------------------------------修改商品信息--------------------------------------------------------\n";
    cout << "请输入您想要修改的商品的商品编号:";
    cin >> n1;
    cout << "\n该商品信息如下:" << endl;
    for (i = 0; i <= n; i++)
    {
        if (n1 == a[i].num)
        {
            cout << "原商品名:" << a[i].name1 << endl;                 //输出被修改的商品信息
            cout << "原商品编号:" << a[i].num << endl;
            cout << "原供应商名称:" << a[i].name2 << endl;
            cout << "原供应商编号:" << a[i].num2 << endl;
            cout << "原供应商联系方式:" << a[i].phone << endl;
            cout << "原商品类型:" << a[i].type << endl;
            cout << "原生产日期:" << a[i].day << endl;
            cout << "原商品价格:" << a[i].price << endl;
            m = i;
        }
    }
    cout << "\n修改后的商品名:";
    cin >> a[m].name1;
    cout << "修改后的商品编号:";
    cin >> a[m].num;
    cout << "修改后的供应商名称:";
    cin >> a[m].name2;
    cout << "修改后的供应商编号:";
    cin >> a[m].num2;
    cout << "修改后的供应商联系方式:";
    cin >> a[m].phone;
    cout << "修改后的商品类型:";
    cin >> a[m].type;
    cout << "修改后的生产日期:";
    cin >> a[m].day;
    cout << "修改后的商品价格:";
    cin >> a[m].price;
    out.open("商品管理.txt");                        //打开文件,将信息导入文件 
    for (i = 0; i <= n; i++)
        out << setw(10) << a[i].name1 << setw(10) << a[i].num << setw(10) << a[i].name2 << setw(10) << a[i].num2 << setw(10) << a[i].phone << setw(10) << a[i].type << setw(10) << a[i].day << setw(10) << a[i].price << endl;    //将信息导入文件 
    out.close();                                     //关闭文件  
    cout << "\n★★★★★★★★★★★★★★★                       修改成功!                           ★★★★★★★★★★★★★★★\n\n";
}

void Delete()                            //定义一个删除信息的函数 
{
    cout << "\n----------------------------------------------------删除商品信息--------------------------------------------------------\n";
    cout << "\n请输入要删除商品的商品编号:";
    cin >> n2;
    cout << "\n该商品信息如下:" << endl;
    for (i = 0; i <= n; i++)
    {
        if (n2 == a[i].num)
        {
            cout << "商品名称:" << a[i].name1 << endl;                  //输出被删除的商品信息 
            cout << "商品编号:" << a[i].num << endl;
            cout << "供应商名称:" << a[i].name2 << endl;
            cout << "供应商编号:" << a[i].num2 << endl;
            cout << "供应商联系电话:" << a[i].phone << endl;
            cout << "商品类型:" << a[i].type << endl;
            cout << "生产日期:" << a[i].day << endl;
            cout << "商品价格:" << a[i].price << endl;
            cout << endl;
            m = i;
        }
    }
    cout << "确定删除?" << endl;
    cout << "确定请输入1" << "		" << "取消请输入除1外任意键返回主菜单\n\n";
    cout << "请输入:";
    cin >> b;
    if (b == 1)
    {
        for (i = 0; i < n; i++)
        {
            if (n2 == a[i].num)
            {
                a[i].name1 = a[i + 1].name1;               //使用后一项覆盖前一项的方法达到删除目的 
                a[i].num = a[i + 1].num;
                a[i].name2 = a[i + 1].name2;
                a[i].num2 = a[i + 1].num2;
                a[i].phone = a[i + 1].phone;
                a[i].type = a[i + 1].type;
                a[i].day = a[i + 1].day;
                a[i].price = a[i + 1].price;
                n--;
            }
        }
        out.open("商品管理.txt");
        for (i = 0; i < n; i++)
            out << setw(10) << a[i].name1 << setw(10) << a[i].num << setw(10) << a[i].name2 << setw(10) << a[i].num2 << setw(10) << a[i].phone << setw(10) << a[i].type << setw(10) << a[i].day << setw(10) << a[i].price << endl;    //写入文件 
        out.close();
        cout << "\n\n删除成功!\n\n";
        cout << "输入任意键返回主菜单";
    }

}

void Search()                          //定义一个查询信息的函数 
{
    cout << "\n----------------------------------------------------查询商品信息--------------------------------------------------------\n";
    cout << "请选择你要进行的操作:\n";
    cout << "1.按商品名查询\n";
    cout << "2.按供应商名称查询\n";
    cout << "3.按条件组合查询\n\n";
    cout << "请输入:" << endl;
    cin >> z;
    switch (z)                         //另外使用switch函数 
    {
    case 1:
        //按商品名查询 
        system("cls");
        cout << "\n-----------------------------------------------------请输入商品名-------------------------------------------------------\n";
        cin >> cx1;
        cout << endl;
        for (i = 0; i <= n; i++)
        {
            if (cx1 == a[i].name1)
            {
                cout << "商品名:" << a[i].name1 << endl;                 //输出被修改的商品信息
                cout << "商品编号:" << a[i].num << endl;
                cout << "供应商名称:" << a[i].name2 << endl;
                cout << "供应商编号:" << a[i].num2 << endl;
                cout << "供应商联系电话:" << a[i].phone << endl;
                cout << "商品类型:" << a[i].type << endl;
                cout << "生产日期:" << a[i].day << endl;
                cout << "商品价格:" << a[i].price << endl;
                cout << endl;
                flag1 = 1;
            }
        }
        if (flag1 == 1)
            cout << "\n★★★★★★★★★★★★★★★                       查询成功!                           ★★★★★★★★★★★★★★★\n";
        else
            cout << "\n★★★★★★★★★★★★                 查询失败,没有此商品,请重试!                           ★★★★★★★★★★★\n" << endl;
        break;

    case 2:
        //按供应商名称查询
        system("cls");
        cout << "\n----------------------------------------------------请输入供应商名称------------------------------------------------------\n";
        cin >> cx2;
        cout << endl;
        for (i = 0; i <= n; i++)
        {
            if (cx2 == a[i].name2)
            {
                cout << "商品名:" << a[i].name1 << endl;                 //输出被修改的商品信息
                cout << "商品编号:" << a[i].num << endl;
                cout << "供应商名称:" << a[i].name2 << endl;
                cout << "供应商编号:" << a[i].num2 << endl;
                cout << "供应商联系方式:" << a[i].phone << endl;
                cout << "商品类型:" << a[i].type << endl;
                cout << "生产日期:" << a[i].day << endl;
                cout << "商品价格:" << a[i].price << endl;
                cout << endl;
                flag2 = 1;
            }
        }
        if (flag2 == 1)
            cout << "\n★★★★★★★★★★★★★★★                       查询成功!                           ★★★★★★★★★★★★★★★\n";
        if (flag2 == 0)
            cout << "\n★★★★★★★★★★★★★                 查询失败,没有此商品,请重试!                           ★★★★★★★★★★★\n" << endl;
        break;

    case 3:
        //条件组合查询
        system("cls");
        cout << "\n------------------------------------------请输入任意两个商品属性(除价格外)--------------------------------------------\n";
        cin >> cx3;
        cin >> cx4;
        cout << endl;
        for (i = 0; i <= n; i++)
        {
            if (cx3 == a[i].num || cx3 == a[i].name1 || cx3 == a[i].name2 || cx3 == a[i].type || cx3 == a[i].day || cx3 == a[i].num2)
            {
                a[t] = a[i];
                j++;
            }
        }
        for (j = 0; j <= t; j++)
        {
            if (cx4 == a[j].num || cx4 == a[j].name1 || cx4 == a[j].name2 || cx4 == a[j].type || cx4 == a[j].day || cx4 == a[i].num2)
            {
                cout << "商品名:" << a[j].name1 << endl;                 //输出被修改的商品信息
                cout << "商品编号:" << a[j].num << endl;
                cout << "供应商名称:" << a[j].name2 << endl;
                cout << "供应商编号:" << a[j].num2 << endl;
                cout << "供应商联系电话:" << a[j].phone << endl;
                cout << "商品类型:" << a[j].type << endl;
                cout << "生产日期:" << a[j].day << endl;
                cout << "商品价格:" << a[j].price << endl;
                cout << endl;
                flag3 = 1;
            }
            if (flag1 == 1)
                cout << "\n★★★★★★★★★★★★★★★                       查询成功!                           ★★★★★★★★★★★★★★★\n";
            if (flag1 == 0)
                cout << "\n★★★★★★★★★★★★★                 查询失败,没有此商品,请重试!                           ★★★★★★★★★★★\n" << endl;
        }
    }
}

void main_menu()                      //欢迎界面 
{
    cout << "\n-------------------------------------------------欢迎进入商品管理系统!------------------------------------------------";
    int h;
    cout << "\n\n★★★★★★★★★★★★★★                     请选择你要进行的操作:                     ★★★★★★★★★★★★★★";
    cout << "\n\n★★★★★★★★★★★★★★                       1.录入商品信息                           ★★★★★★★★★★★★★★\n";
    cout << "\n★★★★★★★★★★★★★★                       2.浏览商品信息                           ★★★★★★★★★★★★★★\n";
    cout << "\n★★★★★★★★★★★★★★                       3.修改商品信息                           ★★★★★★★★★★★★★★\n";
    cout << "\n★★★★★★★★★★★★★★                       4.删除商品信息                           ★★★★★★★★★★★★★★\n";
    cout << "\n★★★★★★★★★★★★★★                       5.查询商品信息                           ★★★★★★★★★★★★★★\n";
    cout << "\n★★★★★★★★★★★★★★                       6.安全退出系统                          ★★★★★★★★★★★★★★";
    cout << "\n\n                                                      ";
    cout << "\n                            请输入:";
    cin >> h;
    system("cls");                               //清屏 
    switch (h)
    {
    case 1:
        Input();
        system("pause");
        system("cls");                      //清屏 
        main_menu();
        break;
    case 2:
        Browse();
        system("pause");
        system("cls");
        main_menu();
        break;
    case 3:
        Modify();
        system("pause");
        system("cls");
        main_menu();
        break;
    case 4:
        Delete();
        system("pause");
        system("cls");
        main_menu();
        break;
    case 5:
        Search();
        system("pause");
        system("cls");
        main_menu();
        break;
    case 6:
        cout << "\n------------------------------------您已经安全退出商品管理系统!感谢您的使用!------------------------------------------\n";
        break;
    default:
        system("cls");
        cout << "\n★★★★★★★★★★★★★                       错误输入,请重试!                           ★★★★★★★★★★★★★\n";
        system("pause");
        system("cls");
        main_menu();
        break;
    }
}

此两个文件项目是本人大二上学期cpp课设的大作业,留下来仅作参考和记录

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值