鱼C论坛

 找回密码
 立即注册
查看: 2273|回复: 12

[已解决]快速排序的问题

[复制链接]
发表于 2022-4-3 22:03:25 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 孤世星辰 于 2022-4-6 09:44 编辑

1.png

  1. #pragma once
  2. #include<iostream>
  3. using std::cout, std::endl, std::cin, std::string;
  4. #include<string>

  5. class Worker
  6. {
  7. public:
  8.         //显示个人信息
  9.         virtual void showInfo() = 0;

  10.         //获取岗位名称
  11.         virtual string getDeptName() = 0;

  12.         int m_ID;
  13.         string m_Name;
  14.         int m_DeptID;

  15. };


  16. #pragma once
  17. #include<iostream>
  18. #include"worker.h"
  19. using std::cout, std::endl, std::cin, std::string;
  20. #include"employee.h"
  21. #include"manager.h"
  22. #include"boss.h"

  23. #include<fstream>
  24. #define FILENAME "empFile.txt"

  25. class WorkerManager
  26. {
  27. public:

  28.         WorkerManager();

  29.         void showMenu();

  30.         void ExitSystem();

  31.         //记录职工人数
  32.         int m_EmpNum;

  33.         //职工数组指针
  34.         Worker ** m_EmpArray;

  35.         //添加职工
  36.         void Add_Emp();

  37.         //保存文件
  38.         void save();

  39.         //判断文件是否为空
  40.         bool m_FileIsEmpty;

  41.         //统计文件中人数
  42.         int get_EmpNUm();

  43.         //初始化员工
  44.         void init_Emp();

  45.         //显示职工
  46.         void Show_Emp();

  47.         //判断职工是否存在  如果存在返回数组中位置,不存在返回-1
  48.         int IsExist(int id);

  49.         //删除职工
  50.         void Del_Emp();

  51.         //修改职工
  52.         void Mod_Emp();

  53.         //查找职工
  54.         void Find_Emp();

  55.         //按照职工编号进行排序
  56.         void Sort_Emp();

  57.         //快速排序
  58.         void quick_Sort(Worker * array[],int left,int right);


  59.         ~WorkerManager();

  60. };

  61. #pragma once
  62. #include<iostream>
  63. using std::cout, std::endl, std::cin, std::string;
  64. #include"worker.h"

  65. class Manager:public Worker
  66. {
  67. public:
  68.         Manager(int id, string name, int dID);

  69.         //显示个人信息
  70.         virtual void showInfo();

  71.         //获取岗位名称
  72.         virtual string getDeptName();

  73. };


  74. #pragma once
  75. #include<iostream>
  76. using std::cout, std::endl, std::cin, std::string;
  77. #include"worker.h"

  78. class Employee :public Worker
  79. {
  80. public:
  81.         Employee(int id ,string name ,int dID);

  82.         //显示个人信息
  83.         virtual void showInfo();

  84.         //获取岗位名称
  85.         virtual string getDeptName();
  86. };


  87. #pragma once
  88. #include<iostream>
  89. using std::cout, std::endl, std::cin, std::string;
  90. #include"worker.h"

  91. class Boss :public Worker
  92. {
  93. public:
  94.         Boss(int id, string name, int dID);

  95.         //显示个人信息
  96.         virtual void showInfo();

  97.         //获取岗位名称
  98.         virtual string getDeptName();

  99. };

  100. //下面是源文件


  101. #include<iostream>
  102. #include<string>
  103. #include"workerManager.h"

  104. using std::cout, std::endl, std::cin, std::string;


  105. int main()
  106. {
  107.         WorkerManager wm;

  108.         int choice = 0;

  109.         while (true) {
  110.                
  111.                 wm.showMenu();

  112.                 cout << "请输入您的选择" << endl;
  113.                 cin >> choice;

  114.                 switch (choice)
  115.                 {
  116.                 case 0:wm.ExitSystem();//退出系统
  117.                         break;
  118.                 case 1:wm.Add_Emp();//增加职工
  119.                         break;
  120.                 case 2: wm.Show_Emp();//显示职工
  121.                         break;

  122.                 case 3:wm.Del_Emp();//删除职工
  123.                         break;

  124.                 case 4:wm.Mod_Emp();//修改职工
  125.                         break;

  126.                 case 5:wm.Find_Emp();//查找职工
  127.                         break;
  128.                 case 6:wm.Sort_Emp();//排序职工
  129.                         break;
  130.                 case 7://清空文档
  131.                         break;
  132.                
  133.                 default:
  134.                         system("cls");
  135.                         break;
  136.                 }
  137.         };
  138.        

  139.         system("pause");
  140.         return 0;
  141. }

  142. #include<iostream>
  143. #include<string>
  144. #include<fstream>
  145. #include"workerManager.h"
  146. using std::cout, std :: endl,std::cin, std::string,std::ofstream,std::ifstream,std::ios;


  147. WorkerManager::WorkerManager()
  148. {
  149.         //文件不存在
  150.         ifstream ifs;
  151.         ifs.open(FILENAME, ios::in);//读文件

  152.         if (!ifs.is_open())
  153.         {
  154.                 //cout << "文件不存在" << endl;
  155.                 //初始化属性
  156.                 this->m_EmpNum = 0;

  157.                 this->m_EmpArray = NULL;

  158.                 this->m_FileIsEmpty = true;

  159.                 ifs.close();

  160.                 return;
  161.         }
  162.         //文件存在  数据为空
  163.         char ch;
  164.         ifs >> ch;
  165.         if (ifs.eof())
  166.         {
  167.                 //cout << "文件为空" << endl;
  168.                 //初始化属性
  169.                 this->m_EmpNum = 0;

  170.                 this->m_EmpArray = NULL;

  171.                 this->m_FileIsEmpty = true;

  172.                 ifs.close();

  173.                 return;
  174.         }
  175.         //文件存在,并且有数据
  176.         int num = this->get_EmpNUm();
  177.         cout << "职工人数为:" << num << endl;
  178.         this->m_EmpNum = num;

  179.         //开辟空间
  180.         this->m_EmpArray = new Worker * [this->m_EmpNum];
  181.        
  182.         //将文件数据存入数组
  183.         this->init_Emp();
  184.        
  185.        
  186.        
  187. }




  188. void WorkerManager::showMenu()
  189. {
  190.         cout << "*****************************************" << endl;
  191.         cout << "*********  欢迎使用职工管理系统  ********" << endl;
  192.         cout << "*********    0、退出管理程序    *********" << endl;
  193.         cout << "*********    1、增加职工信息    *********" << endl;
  194.         cout << "*********    2、显示职工信息    *********" << endl;
  195.         cout << "*********    3、删除职工信息    *********" << endl;
  196.         cout << "*********    4、修改职工信息    *********" << endl;
  197.         cout << "*********    5、查找职工信息    *********" << endl;
  198.         cout << "*********    6、按照编号排序    *********" << endl;
  199.         cout << "*********    7、清空所有文档    *********" << endl;
  200.         cout << "*****************************************" << endl;
  201. }

  202. void WorkerManager::ExitSystem()
  203. {
  204.         cout << "欢迎下次使用" << endl;
  205.         system("pause");
  206.         exit(0);//退出程序
  207. }

  208. void WorkerManager::Add_Emp()
  209. {
  210.         cout << "请输入添加职工的数量" << endl;
  211.         int addNum = 0;
  212.         cin >> addNum;
  213.         if (addNum>0)
  214.         {
  215.                 //计算添加空间大小
  216.                 int newSize = this->m_EmpNum + addNum;//新空间大小=原来的记录人数+新增人数
  217.        
  218.                 //开辟新空间
  219.                 Worker** newSpace = new Worker * [newSize];

  220.                 //将原来数据拷贝到新空间
  221.                 if (this->m_EmpNum!=NULL)
  222.                 {
  223.                         for (int i = 0; i < this->m_EmpNum; i++)
  224.                         {
  225.                                 newSpace[i] = this->m_EmpArray[i];
  226.                         }
  227.                 }

  228.                 //添加新数据
  229.                 for (int i = 0; i < addNum; i++)
  230.                 {
  231.                         int id;
  232.                         string name;
  233.                         int dSelect;

  234.                         cout << "请输入第" << i + 1 << "各新职工编号:" << endl;
  235.                         cin >> id;
  236.                         while (1)
  237.                         {
  238.                                 if (IsExist(id)==-1)
  239.                                 {
  240.                                         break;
  241.                                 }
  242.                                 cout << "职工编号已存在,请重新输入!" << endl;
  243.                                 cout << "请输入第" << i + 1 << "各新职工编号:" << endl;
  244.                                 cin >> id;
  245.                         }

  246.                         cout << "请输入第" << i + 1 << "各新职工姓名:" << endl;
  247.                         cin >> name;

  248.                         cout << "请选择该职工岗位:" << endl;
  249.                         cout << "1、普通职工" << endl;
  250.                         cout << "2、经理" << endl;
  251.                         cout << "3、老板" << endl;
  252.                         cin >> dSelect;

  253.                         Worker* worker = NULL;
  254.                         switch (dSelect)
  255.                         {
  256.                         case 1:
  257.                                 worker = new Employee(id, name, 1);
  258.                                 break;
  259.                         case 2:
  260.                                 worker = new Manager(id, name, 2);
  261.                                 break;
  262.                         case 3:
  263.                                 worker = new Boss(id, name, 3);
  264.                                 break;
  265.                         default:
  266.                                 break;
  267.                         }
  268.                         //将创建职工职责,存入数组
  269.                         newSpace[this->m_EmpNum + i] = worker;
  270.                 }

  271.                 //释放原有空间
  272.                 delete[] this->m_EmpArray;

  273.                 //更新新空间的指向
  274.                 this->m_EmpArray = newSpace;

  275.                 //更新新的职工人数
  276.                 this->m_EmpNum = newSize;

  277.                 //更新后职工不为空       
  278.                 this->m_FileIsEmpty = false;

  279.                 cout << "成功添加" << addNum << "名新职工!" << endl;

  280.                 //保存数据到文件中
  281.                 this->save();
  282.         }
  283.         else
  284.         {
  285.                 cout << "输入有误" << endl;
  286.         }

  287.         system("pause");
  288.         system("cls");
  289. }

  290. void WorkerManager:: save()
  291. {
  292.         ofstream ofs;
  293.         ofs.open(FILENAME, ios::out);//用输出方式写文件

  294.         for (int i = 0; i < this->m_EmpNum; i++)
  295.         {
  296.                 ofs << this->m_EmpArray[i]->m_ID << "\t"
  297.                         << this->m_EmpArray[i]->m_Name << "\t"
  298.                         << this->m_EmpArray[i]->m_DeptID << endl;
  299.         }

  300.         ofs.close();
  301. }

  302. int WorkerManager::get_EmpNUm()
  303. {
  304.         ifstream ifs;
  305.         ifs.open(FILENAME, ios::in);//打开文件读文件
  306.        
  307.         int id;
  308.         string name;
  309.         int dID;

  310.         int num = 0;
  311.         while (ifs>>id&&ifs>>name&&ifs>>dID)
  312.         {
  313.                 num++;
  314.         }
  315.         return num;
  316. }

  317. void WorkerManager::init_Emp()
  318. {
  319.         ifstream ifs;
  320.         ifs.open(FILENAME, ios::in);

  321.         int id;
  322.         string name;
  323.         int dId;

  324.         int index = 0;
  325.         while (ifs>>id  &&  ifs>>name  &&  ifs>>dId)
  326.         {
  327.                 Worker * worker = NULL;

  328.                 if (dId==1)
  329.                 {
  330.                         worker = new Employee(id, name, dId);
  331.                 }
  332.                 else if (dId==2)
  333.                 {
  334.                         worker = new Manager(id, name, dId);
  335.                 }
  336.                 else
  337.                 {
  338.                         worker = new Boss(id, name, dId);
  339.                 }
  340.                 this->m_EmpArray[index] = worker;
  341.                 index++;
  342.         }

  343.         ifs.close();
  344. }

  345. void WorkerManager::Show_Emp()
  346. {
  347.         //判断文件是否为空
  348.         if (this->m_FileIsEmpty)
  349.         {
  350.                 cout << "文件不存在或者记录为空!" << endl;
  351.         }
  352.         else
  353.         {
  354.                 for (int i = 0; i < m_EmpNum; i++)
  355.                 {
  356.                         this->m_EmpArray[i]->showInfo();
  357.                 }
  358.         }

  359.         system("pause");
  360.         system("cls");
  361. }

  362. void WorkerManager::Del_Emp()
  363. {
  364.         if (this->m_FileIsEmpty)
  365.         {
  366.                 cout << "文件不存在或者数据为空" << endl;
  367.         }
  368.         else
  369.         {
  370.                 cout << "请输入想要删除职工编号:" << endl;
  371.                 int id = 0;
  372.                 cin >> id;

  373.                 int index = this->IsExist(id);

  374.                 if (index != -1)
  375.                 {
  376.                         for (int i = index; i < this->m_EmpNum; i++)
  377.                         {
  378.                                 this->m_EmpArray[i] = this->m_EmpArray[i + 1];
  379.                         }
  380.                         this->m_EmpNum--;

  381.                         //数据同步更新到文件中
  382.                         this->save();

  383.                         cout << "删除成功!" << endl;

  384.                 }
  385.                 else
  386.                 {
  387.                         cout << "删除失败,未找到该职工" << endl;
  388.                 }
  389.         }

  390.         system("pause");
  391.         system("cls");
  392. }

  393. int WorkerManager::IsExist(int id)
  394. {
  395.         int index = -1;
  396.         for (int i = 0; i < this->m_EmpNum; i++)
  397.         {
  398.                 if (this->m_EmpArray[i]->m_ID == id)
  399.                 {
  400.                         index = i;

  401.                         break;
  402.                 }
  403.         }
  404.         return index;
  405. }

  406. void WorkerManager::Mod_Emp()
  407. {
  408.         if (this->m_FileIsEmpty)
  409.         {
  410.                 cout << "文件不存在或者记录为空" << endl;
  411.         }
  412.         else
  413.         {
  414.                 cout << "请输入修改职工编号:" << endl;
  415.                 int id;
  416.                 cin >> id;

  417.                 int ret = this->IsExist(id);
  418.                 if (ret != -1)
  419.                 {
  420.                         delete this->m_EmpArray[ret];

  421.                         int newId = 0;
  422.                         string newName = "";
  423.                         int dSelect = 0;

  424.                         cout << "查到:" << id << "号职工,请输入新职工号:" << endl;
  425.                         cin >> newId;

  426.                         cout << "请输入新姓名:" << endl;
  427.                         cin >> newName;

  428.                         cout << "请输入新岗位:" << endl;
  429.                         cout << "1、普通职工" << endl;
  430.                         cout << "2、经理" << endl;
  431.                         cout << "3、老板" << endl;
  432.                         cin >> dSelect;

  433.                         Worker* worker = NULL;

  434.                         switch (dSelect)
  435.                         {
  436.                         case 1:
  437.                                 worker = new Employee(newId, newName, dSelect);
  438.                                 break;
  439.                         case 2:
  440.                                 worker = new Manager(newId, newName, dSelect);
  441.                                 break;
  442.                         case 3:
  443.                                 worker = new Boss(newId, newName, dSelect);
  444.                                 break;
  445.                         default:
  446.                                 break;
  447.                         }

  448.                         //更新数据到数组中
  449.                         this->m_EmpArray[ret] = worker;

  450.                         cout << "修改成功!" << endl;

  451.                         this->save();
  452.                 }
  453.                 else
  454.                 {
  455.                         cout << "修改失败,查无此人" << endl;
  456.                 }
  457.         }
  458.         system("pause");
  459.         system("cls");
  460. }

  461. void WorkerManager::Find_Emp()
  462. {
  463.         if (this->m_FileIsEmpty)
  464.         {
  465.                 cout << "文件不存在或者记录为空!" << endl;
  466.         }
  467.         else
  468.         {
  469.                 cout << "请输入查找的方式:" << endl;
  470.                 cout << "1、按照职工的编号查找" << endl;
  471.                 cout << "2、按照职工姓名查找" << endl;

  472.                 int select = 0;
  473.                 cin >> select;

  474.                 if (select==1)
  475.                 {
  476.                         //按照编号查
  477.                         int id;
  478.                         cout << "请输入查找的职工编号:" << endl;
  479.                         cin >> id;

  480.                         int ret=IsExist(id);
  481.                         if (ret!=-1)
  482.                         {
  483.                                 //找到职工
  484.                                 cout << "查找成功!该职工信息如下:" << endl;
  485.                                 this->m_EmpArray[ret]->showInfo();
  486.                         }
  487.                         else
  488.                         {
  489.                                 cout << "查找失败,查无此人" << endl;
  490.                         }
  491.                 }
  492.                 else if (select==2)
  493.                 {
  494.                         //按照姓名查
  495.                         string name;
  496.                         cout << "请输入查找姓名" << endl;
  497.                         cin >> name;

  498.                         bool flag = false;

  499.                         for (int i = 0; i < m_EmpNum; i++)
  500.                         {
  501.                                 if (this->m_EmpArray[i]->m_Name == name)
  502.                                 {
  503.                                         cout << "查找成功,职工编号为"
  504.                                                 << this->m_EmpArray[i]->m_ID
  505.                                                 << "号职工信息如下:" << endl;

  506.                                         flag = true;

  507.                                         this->m_EmpArray[i]->showInfo();
  508.                                 }
  509.                         }

  510.                         if (!flag)
  511.                         {
  512.                                 cout << "查找失败,查无此人!" << endl;
  513.                         }

  514.                 }
  515.                 else
  516.                 {
  517.                         cout << "输入有误!" << endl;
  518.                 }
  519.         }

  520.         system("pause");
  521.         system("cls");
  522. }

  523. void WorkerManager::Sort_Emp()
  524. {
  525.         if (this->m_FileIsEmpty)
  526.         {
  527.                 cout << "文件不存在或者记录为空!" << endl;
  528.         }
  529.         else
  530.         {
  531.                 cout << "请选择排序方式:" << endl;
  532.                 cout << "1、按照职工号升序排列" << endl;
  533.                 cout << "2、按照职工号降序排列" << endl;

  534.                 int select = 0;
  535.                 cin >> select;

  536.                 if (select==1)
  537.                 {
  538.                         quick_Sort(m_EmpArray, 0, m_EmpNum);
  539.                         save();
  540.                 }


  541.         }
  542. }

  543. void WorkerManager::quick_Sort(Worker* m_EmpArray[], int left, int right)
  544. {
  545.         int pivot;
  546.         int i = left;
  547.         int j = right;

  548.         pivot = i;
  549.         while( i <= j)
  550.         {
  551.                 while (m_EmpArray[i]->m_ID  < m_EmpArray[pivot]->m_ID)
  552.                 {
  553.                         i++;
  554.                 }
  555.                 while (m_EmpArray[j]->m_ID  > m_EmpArray[pivot]->m_ID)
  556.                 {
  557.                         j--;
  558.                 }

  559.                 if (i <= j)
  560.                 {
  561.                         Worker* temp = m_EmpArray[i];
  562.                         m_EmpArray[i] = m_EmpArray[j];
  563.                         m_EmpArray[j] = temp;
  564.                         i++;
  565.                         j--;
  566.                 }
  567.         }

  568.         if (left<j)
  569.         {
  570.                 quick_Sort(m_EmpArray, left, j);
  571.         }
  572.         if (i<left)
  573.         {
  574.                 quick_Sort(m_EmpArray, i, left);
  575.         }

  576. }

  577. WorkerManager::~WorkerManager()
  578. {
  579.         if (this->m_EmpArray != NULL)
  580.         {
  581.                 delete[] this->m_EmpArray;
  582.                 this->m_EmpArray = NULL;
  583.         }
  584. }

  585. #include"manager.h"

  586. Manager::Manager(int id, string name, int dID)
  587. {
  588.         this->m_ID = id;
  589.         this->m_DeptID = dID;
  590.         this->m_Name = name;

  591. }

  592. //显示个人信息
  593. void Manager ::showInfo()
  594. {
  595.         cout << "职工编号" << this->m_ID
  596.                 << "\t职工姓名" << this->m_Name
  597.                 << "\t岗位" << this->getDeptName()
  598.                 << "\t岗位职责:完成老板任务,下发任务给员工" << endl;
  599. }

  600. //获取岗位名称
  601. string Manager ::getDeptName()
  602. {
  603.         return string("经理");
  604. }

  605. #include"employee.h"


  606. Employee::Employee(int id, string name, int dID)
  607. {
  608.         this->m_ID = id;
  609.         this->m_Name = name;
  610.         this->m_DeptID=dID;
  611. }

  612. //显示个人信息
  613. void Employee:: showInfo()
  614. {
  615.         cout << "职工编号" << this->m_ID
  616.                 << "\t职工姓名" << this->m_Name
  617.                 << "\t岗位" << this->getDeptName()
  618.                 << "\t岗位职责:完成经理交给的任务" << endl;
  619. }

  620. //获取岗位名称
  621. string Employee::getDeptName()
  622. {
  623.         return string("员工");
  624. }

  625. #include"boss.h"

  626. Boss::Boss(int id, string name, int dID)
  627. {
  628.         this->m_ID = id;
  629.         this->m_DeptID = dID;
  630.         this->m_Name = name;
  631. }

  632. //显示个人信息
  633. void Boss::showInfo()
  634. {
  635.         cout << "职工编号" << this->m_ID
  636.                 << "\t职工姓名" << this->m_Name
  637.                 << "\t岗位" << this->getDeptName()
  638.                 << "\t岗位职责:管理公司所有任务" << endl;
  639. }

  640. //获取岗位名称
  641. string Boss::getDeptName()
  642. {
  643.         return string("老板");
  644. }
复制代码



程序大概意思就是添加联系人,联系人里面有员工,老板,经理,三种,然后每个人因为类型不一样所以不能放在一个数组里面,然后就用他的父类指针worker代指,从而实现把这些类型不一样的数据放在同一个数组中,但是我的快速排序出了问题不知道哪里错了
最佳答案
2022-4-5 23:03:50
孤世星辰 发表于 2022-4-4 19:38
emmm我重新加了一点点,我觉得有关系的代码都发出来了,老师你可以看一下

你的main函数呢?
要发完整代码,你只贴和问题有关系的代码不行,你只贴这些代码,我并不知道这个代码的上下文环境
更重要的是我没法debug,我需要完整的代码,编译,然后调试运行
你怎么debug的?用眼睛盯着代码一行一行的看吗?
一遍来说,debug是把程序载入内存,一步一步的执行
你不发完整代码,我这么编译,调试?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-4-6 10:28:31 | 显示全部楼层
人造人 发表于 2022-4-5 23:03
你的main函数呢?
要发完整代码,你只贴和问题有关系的代码不行,你只贴这些代码,我并不知道这个代码的 ...


谢谢老师,我之前不知道怎么debug,然后去网上搜了一下,自己试了试,发现是  j   这个变量的值没传好,我传的是数组长度,但是其实是要给数组长度-1,现在已经运行成功了,以后我也会自己debug了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-4 14:18:18 | 显示全部楼层
代码要发完整
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-4 15:53:28 | 显示全部楼层
有点像野指针滴样子(我也不确定)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-4-4 19:38:44 | 显示全部楼层

emmm我重新加了一点点,我觉得有关系的代码都发出来了,老师你可以看一下
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-4-4 19:39:39 | 显示全部楼层
FK二十一 发表于 2022-4-4 15:53
有点像野指针滴样子(我也不确定)

不清楚呢,我也感觉就是传的数组指针有问题,但是我又不知道怎么改
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-4-4 21:50:11 | 显示全部楼层
孤世星辰 发表于 2022-4-4 19:38
emmm我重新加了一点点,我觉得有关系的代码都发出来了,老师你可以看一下

这里面顶贴有用嘛....
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-5 23:03:50 | 显示全部楼层    本楼为最佳答案   
孤世星辰 发表于 2022-4-4 19:38
emmm我重新加了一点点,我觉得有关系的代码都发出来了,老师你可以看一下

你的main函数呢?
要发完整代码,你只贴和问题有关系的代码不行,你只贴这些代码,我并不知道这个代码的上下文环境
更重要的是我没法debug,我需要完整的代码,编译,然后调试运行
你怎么debug的?用眼睛盯着代码一行一行的看吗?
一遍来说,debug是把程序载入内存,一步一步的执行
你不发完整代码,我这么编译,调试?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-4-6 09:38:44 | 显示全部楼层
人造人 发表于 2022-4-5 23:03
你的main函数呢?
要发完整代码,你只贴和问题有关系的代码不行,你只贴这些代码,我并不知道这个代码的 ...

哦哦哦对不起,我这就改
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-6 22:02:05 | 显示全部楼层
1.png
2.png
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-7 13:42:36 | 显示全部楼层
代码重发一下,像这样发
https://fishc.com.cn/forum.php?m ... 346&pid=5796076
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-4-12 18:00:53 | 显示全部楼层
人造人 发表于 2022-4-7 13:42
代码重发一下,像这样发
https://fishc.com.cn/forum.php?mod=redirect&goto=findpost&ptid=211346&pid=57 ...

哦哦哦我以后都按照这样发
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-14 14:58:34 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-24 13:31

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表