#include<iostream>
#include<string>
#include<fstream>
using namespace std;
#define Max 1000
static int s = 0;//货物的总量
string zh = "1";   //设置进入的账号
char mima[7] = "123456";  //设置密码
void menu();
void pai();
void duqu()
{
    ofstream outfile1("1.txt", ios::out);//初始化文件,清空存储的内容
    if (!outfile1)
    {
        cout << "打开文件失败!" << endl;
        exit(1);
    }
    outfile1.close();
    string productname[Max];//物品名称
    int  productnum[Max];//物品编号
    int num[Max];//物品的数量
    string  name[Max];//管理人名
    string str1, str2;
    cout << "是否初始化管理的货物" << endl;
    cin >> str2;
    if (str2 == "是")
    {
        ofstream outfile("1.txt", ios::out);
        if (!outfile)
        {
            cerr << "打开失败" << endl;
            exit(1);
        }
        for (int i = 0; i < Max; i++)
        {
            cout << "请输入要添加的物品的名称" << endl;
            cin >> productname[s];
            outfile << productname[s] << "  ";
            cout << "请输入要添加的物品的编号" << endl;
            cin >> productnum[s];
            outfile << productnum[s] << "  ";
            cout << "请输入要添加的物品的数量" << endl;
            cin >> num[s];
            outfile << num[s] << "  ";
            cout << "请输入要添加的物品的收货人" << endl;
            cin >> name[s];
            outfile << name[s] << "  ";
            s++;
            cout << "是否继续添加" << endl;
            cin >> str1;
            if (str1 == "否")
            {
                break;
            }
        }
        outfile.close();
    }
}
void add()
{
    string productname[Max];//物品名称
    int  productnum[Max];//物品编号
    int num[Max];//物品的数量
    string  name[Max];//人名     
    ofstream outfile("1.txt", ios::app);
    if (!outfile)
    {
        cerr << "打开失败" << endl;
        exit(1);
    }
    cout << "请输入要添加的物品的名称" << endl;
    cin >> productname[s];
    outfile << productname[s] << "  ";
    cout << "请输入要添加的物品的编号" << endl;
    cin >> productnum[s];
    outfile << productnum[s] << "  ";
    cout << "请输入要添加的物品的数量" << endl;
    cin >> num[s];
    outfile << num[s] << "  ";
    cout << "请输入要添加的物品的管理人" << endl;
    cin >> name[s];
    outfile << name[s] << "  ";
    s++;
    outfile.close();
    menu();
}
void  sera()
{
    system("cls");
    pai();
    string productname[Max];//物品名称
    int  productnum[Max];//物品编号
    int num[Max];//物品的数量
    string  name[Max];//人名
    ifstream infile("1.txt", ios::in);
    if (!infile)
    {
        cout << "打开文件失败" << endl;
        exit(1);
    }
    cout << "物品名称   " << "物品编号   " << "物品的数量   "
        << "管理人" << endl;
    for (int j = 0; j < s; j++)
    {
        infile >> productname[j];
        cout << productname[j] << "         ";
        infile >> productnum[j];
        cout << productnum[j] << "          ";
        infile >> num[j];
        cout << num[j] << "           ";
        infile >> name[j];
        cout << name[j] << endl;
    }
    infile.close();
    menu();
}
void Delete()
{
    system("cls");
    int k;
    string productname[Max];//物品名称
    int  productnum[Max];//物品编号
    int num[Max];//物品的数量
    string  name[Max];//人名
    ifstream infile("1.txt", ios::in);
    if (!infile)
    {
        cout << "打开文件失败" << endl;
        exit(1);
    }
    cout << "物品名称   " << "物品编号   " << "物品的数量   "
        << "管理人名" << endl;
    for (int j = 0; j < s; j++)
    {
        infile >> productname[j];
        cout << productname[j];
        infile >> productnum[j];
        cout << productnum[j] << "        ";
        infile >> num[j];
        cout << num[j] << "          ";
        infile >> name[j];
        cout << name[j] << "            ";
        cout << endl;
    }
    infile.close();
    ofstream outfile("1.txt", ios::out);
    if (!outfile)
    {
        cerr << "打开失败" << endl;
        exit(1);
    }
    cout << "你想删除第几个" << endl;
    cin >> k;
    for (int i = 0; i < s; i++)
    {
        if (i != k - 1)
        {
            outfile << productname[i] << "  ";
            outfile << productnum[i] << "  ";
            outfile << num[i] << "  ";
            outfile << name[i] << "  ";
        }
    }
    s--;
    outfile.close();
    menu();
}
void gai()
{
    system("cls");
    string productname[Max];//物品名称
    int  productnum[Max];//物品编号
    int num[Max];//物品的数量
    string  name[Max];//人名
    int n1;
    int z;
    string productname1;
    int productnum1;
    int num1;
    string name1;
    ifstream infile("1.txt", ios::in);
    if (!infile)
    {
        cerr << "打开失败" << endl;
        exit(1);
    }
    cout << "物品名称   " << "物品编号   " << "物品的数量   "
        << "管理人名" << endl;
    for (int k = 0; k < s; k++)
    {
        infile >> productname[k];
        cout << productname[k] << "       ";
        infile >> productnum[k];
        cout << productnum[k] << "        ";
        infile >> num[k];
        cout << num[k] << "         ";
        infile >> name[k];
        cout << name[k] << "         ";
        cout << endl;
    }
    infile.close();
    cout << "请输入要修改第几个" << endl;
    cin >> n1;
    for (int i = 0; i <= s; i++)
    {
        if (n1 - 1 == i)
        {
            cout << "1.修改物品名称" << endl;
            cout << "2.修改物品编码" << endl;
            cout << "3.修改物品数量" << endl;
            cout << "4.管理人名" << endl;
            cout << "请输入序号" << endl;
            cin >> z;
            switch (z)
            {
            case 1: cout << "请输入要修改的物品的名字" << endl;
                cin >> productname1;
                productname[i] = productname1;
                cout << "修改成功!" << endl;
                break;
            case 2:  cout << "请输入要修改的物品的编码" << endl;
                cin >> productnum1;
                productnum[i] = productnum1;
                cout << "修改成功!" << endl;
                break;
            case 3:cout << "请输入要修改的物品的数量" << endl;
                cin >> num1;
                num[i] = num1;
                cout << "修改成功!" << endl;
                break;
            case 4:cout << "请输入修改的管理人的名字" << endl;
                cin >> name1;
                name[i] = name1;
                cout << "修改成功!" << endl;
                break;
            default:
                cout << "请输入标准的功能序号" << endl;
                gai();
                break;
            }
            break;
        }

}
    ofstream outfile("1.txt", ios::out);
    if (!outfile)
    {
        cerr << "打开失败" << endl;
        exit(1);
    }
    for (int j = 0; j < s; j++)
    {
        outfile << productname[j] << "  ";
        outfile << productnum[j] << "  ";
        outfile << num[j] << "  ";
        outfile << name[j] << "  ";
    }
    outfile.close();
    menu();
}
void menu()
{
    int n;
    bool b = true;
    system("pause");
    system("cls");
    cout << "**********************" << endl;
    cout << "*******功能序号*******" << endl;
    cout << "1.查询货物的信息" << endl;
    cout << "2.添加货物信息" << endl;//添加信息
    cout << "3.删除货物信息" << endl;//删除信息
    cout << "4.修改信息" << endl;
    cout << "5.退出程序" << endl;
    cout << "**********************" << endl;
    do
    {
        cin >> n;
        switch (n)
        {
        case 1:   sera();
            break;
        case 2:  add();
            break;
        case 3:  Delete();
            break;
        case 4:gai();
            break;
        case 5: b = false;
            exit(0);
            break;
        default:cout << "请输入标准的功能序号" << endl;
            menu();
        }
    } while (b);
}
void login()
{

bool   bol1 = true;
    string zh1;
    char mima1[7];

int i = 0;
    cout << "********欢迎使用物流信息管理系统********" << endl;
    cout << "****************************************" << endl;
    cout << "******************登录******************" << endl;
    cout << "*********账号:";
    cin >> zh1;
    cout << endl;
    cout << "*********密码:";
    cin >> mima1;
    cout << endl;
    if ((zh1 == zh && !strcmp(mima1, mima)))
    {
        cout << "****************登录成功!*****************" << endl;
        system("pause");
        system("cls");
        cout << "请先建立文件" << endl;
        duqu();
        menu();
        return;
    }
    else
    {
        cout << "****************登录失败!*****************" << endl;
        cout << "****************请重新登录*****************" << endl;
        login();
    }
}
void pai() {
    string productname[Max];//物品名称
    int  productnum[Max];//物品编号
    int num[Max];//物品的数量
    string  name[Max];//人名
    string productname1;
    int  productnum1;
    int num1;
    string  name1;
    ifstream infile("1.txt", ios::in);
    if (!infile)
    {
        cout << "打开文件失败" << endl;
        exit(1);
    }
    for (int j = 0; j < s; j++)
    {
        infile >> productname[j];
        infile >> productnum[j];
        infile >> num[j];
        infile >> name[j];
    }
    infile.close();
    for (int i = 0; i < s - 1; i++)
    {
        for (int k = i + 1; k < s; k++)
        {
            if (num[i] > num[k])
            {
                productname1 = productname[i];
                productnum1 = productnum[i];
                num1 = num[i];
                name1 = name[i];
                productname[i] = productname[k];
                productnum[i] = productnum[k];
                num[i] = num[k];
                name[i] = name[k];
                productname[i] = productname1;
                productnum[k] = productnum1;
                num[k] = num1;
                name[k] = name1;
            }
        }
    }
    ofstream outfile("1.txt", ios::out);
    if (!outfile)
    {
        cerr << "打开失败" << endl;
        exit(1);
    }
    for (int t = 0; t < s; t++)
    {
        outfile << productname[t] << "  ";
        outfile << productnum[t] << "  ";
        outfile << num[t] << "  ";
        outfile << name[t] << "  ";
    }
    outfile.close();
}
int main()
{
     login();
    return 0;
}

源码仅供参考!

关于C++课设————物流信息管理系统的源码相关推荐

  1. C语言物流信息管理系统实践,[源码和文档分享]基于C语言的物流配送管理信息系统...

    一 需求分析 系统需要实现的功能如下: (一)各种基本数据的录入 配送路线基本信息录入 路线经停站点基本信息录入 站点经停车辆基本信息录入 其它信息录入 (二)各种基本数据的修改 即:允许对已经录入的 ...

  2. C语言课设-----工资管理系统(附全部源码)

    C语言课设-----工资管理系统(附全部源码) 本系统分三个部分: 1.出售金鱼 2.数字菱形 3.工资管理系统 (ps:另外添加了登录界面 id:qwq password:123 可自己在代码里再更 ...

  3. 计算机毕业设计Java高校排课管理系统(源码+系统+mysql数据库+lw文档)

    计算机毕业设计Java高校排课管理系统(源码+系统+mysql数据库+lw文档) 计算机毕业设计Java高校排课管理系统(源码+系统+mysql数据库+lw文档) 本源码技术栈: 项目架构:B/S架构 ...

  4. 计算机毕业设计Java疫情网课管理系统(源码+系统+mysql数据库+Lw文档)

    计算机毕业设计Java疫情网课管理系统(源码+系统+mysql数据库+Lw文档) 计算机毕业设计Java疫情网课管理系统(源码+系统+mysql数据库+Lw文档) 本源码技术栈: 项目架构:B/S架构 ...

  5. JAVA计算机毕业设计银行贷款管理系统Mybatis+源码+数据库+lw文档+系统+调试部署

    JAVA计算机毕业设计银行贷款管理系统Mybatis+源码+数据库+lw文档+系统+调试部署 JAVA计算机毕业设计银行贷款管理系统Mybatis+源码+数据库+lw文档+系统+调试部署 本源码技术栈 ...

  6. java毕业生设计贝儿米幼儿教育管理系统计算机源码+系统+mysql+调试部署+lw

    java毕业生设计贝儿米幼儿教育管理系统计算机源码+系统+mysql+调试部署+lw java毕业生设计贝儿米幼儿教育管理系统计算机源码+系统+mysql+调试部署+lw 本源码技术栈: 项目架构:B ...

  7. java毕业设计教师工作量管理系统mybatis+源码+调试部署+系统+数据库+lw

    java毕业设计教师工作量管理系统mybatis+源码+调试部署+系统+数据库+lw java毕业设计教师工作量管理系统mybatis+源码+调试部署+系统+数据库+lw 本源码技术栈: 项目架构:B ...

  8. java毕业生设计一中体育馆管理系统计算机源码+系统+mysql+调试部署+lw

    java毕业生设计一中体育馆管理系统计算机源码+系统+mysql+调试部署+lw java毕业生设计一中体育馆管理系统计算机源码+系统+mysql+调试部署+lw 本源码技术栈: 项目架构:B/S架构 ...

  9. java毕业生设计药房药品采购集中管理系统计算机源码+系统+mysql+调试部署+lw

    java毕业生设计药房药品采购集中管理系统计算机源码+系统+mysql+调试部署+lw java毕业生设计药房药品采购集中管理系统计算机源码+系统+mysql+调试部署+lw 本源码技术栈: 项目架构 ...

最新文章

  1. 一天 用户旅程_439天的旅程改变了我的生活
  2. Mach-O 二进制文件解析
  3. Spring Boot Admin 2.2.0发布,支持最新Spring Boot/Cloud之外,新增中文展示!
  4. Alpha 冲刺 (9/10)
  5. Fragment 生命周期的详情
  6. DCMTK:测试VR类的compare()运算符
  7. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(13)-权限设计
  8. SpringBoot设置首页(默认页)跳转
  9. 人脸识别腾讯安排上了!孩子不能再任意冒用家长身份信息
  10. 不需要PM3/PN532也可以搞定加密卡!利用小米9、小米手环NFC模拟加密门禁卡的傻瓜式保姆级教程
  11. Spring框架---全面详解【无比详细,学习总结】
  12. Fiddler自动回复器伪造回复
  13. win7 共享打印机后,客户端连接提示:打印机已删除(0x00000709)
  14. 基于增强现实的室内导航系统如何设计架构
  15. 网站开发进阶(七十):CSS 实现圆角有立体感的 DIV 边框
  16. C语言规定 在一个源程序中 main函数,C语言规定:在一个源程序中,main函数的位置()A.必须在程序的最开始B.必须在系统调用的库函数的_搜题易...
  17. VUE 爬坑之旅 -- vue 项目中将简体转换为繁体
  18. linux彻底清除磁盘阵列,Linux下彻底关闭某个RAID磁盘阵列
  19. 589. N 叉树的前序遍历(javascript)589. N-ary Tree Preorder Traversal
  20. 【二】、什么是抽象数据类型

热门文章

  1. nao机器人Python+pycharm+naoqi平台搭建
  2. 爬虫数据解析的三种方式
  3. Norflash 驱动
  4. windows 10 双系统删除ubuntu系统分区,导致grub rescue错误
  5. MySQL 查询中的分页思路的优化
  6. 【MySQL】mysql文本类型, 长文本
  7. 通俗易懂的5种IO模型文章
  8. [removed]window.close()不管用?
  9. 深圳3d可视化建模,数字孪生智慧工厂3D模型开发,智慧城市园区三维模型
  10. 登录页面的密码的显示与隐藏