功能模块设计

基于C++语言实现的小超市食品管理系统,采用面向对象的思维进行设计,包含以下功能模块:

  • 显示库存及销售记录
  • 添加库存食品
  • 删除库存食品
  • 修改库存食品
  • 查询库存食品
  • 库存食品排序
  • 食品销售
  • 清空系统数据

主要运行界面

  • 主菜单界面

主菜单界面

  • 显示库存及销售记录界面

显示库存及销售记录界面

  • 添加库存食品界面

添加库存食品界面

  • 食品销售界面

食品销售界面


系统完整代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <fstream>
#include <vector>
#include <sstream>
#include <ctime>
using namespace std;
//工具类
class Tool
{
public:
//获取系统当前时间
static string getTime()
{
time_t t = time(NULL);
struct tm* now = localtime(&t);
std::stringstream time;
time << now->tm_year + 1900 << "-";
time << now->tm_mon + 1 << "-";
time << now->tm_mday << "_";
time << now->tm_hour << ":";
time << now->tm_min << ":";
time << now->tm_sec;
return time.str();
}
};
//食品类
class Food
{
public:
string foodName; //食品名称
double foodAmount; //食品库存量
string foodUnit; //食品单位 如 吨、艘、个、斤
string foodKind; //食品种类
//无参构造
Food()
{
}
//有参构造
Food(string foodName, double foodAmount, string foodUnit,string foodKind)
{
this->foodName = foodName;
this->foodAmount = foodAmount;
this->foodUnit = foodUnit;
this->foodKind = foodKind;
}
//析构
~Food()
{
}
//输出
void showFdInfo()
{
cout << left << setw(16) << foodName;
cout << left << setw(10) << foodAmount;
cout << left << setw(10) << foodUnit;
cout << left << setw(10) << foodKind << endl;
}
//输出属性名,只显示总积分
static void showHeader()
{
cout << left << setw(16) << "名称";
cout << left << setw(10) << "库存量";
cout << left << setw(10) << "单位";
cout << left << setw(10) << "种类" << endl;
}
};
//销售记录类
class Record
{
public:
string foodName; //食品名称
double foodAmount; //变更数量
string foodUnit; //食品单位
double foodPrice; //售出单价
double eachPrice; //本单收入
string updateTime; //发生时间
double totalPrice; //总的销售额 = 收入 - |支出|

void showRecInfo()
{
cout << left << setw(12) << foodName;
cout << left << setw(8) << foodAmount;
cout << left << setw(8) << foodUnit;
cout << left << setw(10) << foodPrice;
cout << left << setw(10) << eachPrice;
cout << left << setw(20) << updateTime << endl;
}
//输出属性名
static void showHeader()
{
cout << left << setw(12) << "名称";
cout << left << setw(8) << "数量";
cout << left << setw(8) << "单位";
cout << left << setw(10) << "单价";
cout << left << setw(10) << "本单收入";
cout << left << setw(20) << "销售时间" << endl;
}
};

//超市管理系统类
class FoodSystem
{
public:
vector<Food> flist; //货物库存
vector<Record> rlist; //销售记录
FoodSystem() { }
FoodSystem(vector<Food> flist,vector<Record> rlist)
{
this->flist = flist;
this->rlist = rlist;
}

//初始化
void init()
{
readFile(); //读取文件
}

//读取文件
void readFile()
{
//读取库存文件
ifstream ifs;
ifs.open("flist.txt", ios::in);
Food f;
while(ifs >> f.foodName >> f.foodAmount >> f.foodUnit >> f.foodKind)
{
flist.push_back(f);
}
ifs.close();
//读取操作记录文件
ifstream jfs;
jfs.open("rlist.txt", ios::in);
Record r;
while(jfs >> r.foodName >> r.foodAmount >> r.foodUnit >> r.foodPrice >> r.eachPrice >> r.updateTime >> r.totalPrice)
{
rlist.push_back(r);
}
jfs.close();
}
//写入文件
void writeFile()
{
//写入库存文件
ofstream ofs;
ofs.open("flist.txt", ios::out);
for (int i = 0; i < flist.size(); i++)
{
ofs << flist[i].foodName << " " << flist[i].foodAmount << " " << flist[i].foodUnit << " " << flist[i].foodKind << endl;
}
ofs.close();
//写入操作记录文件
ofstream pfs;
pfs.open("rlist.txt", ios::out);
for (int i = 0; i < rlist.size(); i++)
{
pfs << rlist[i].foodName << " " << rlist[i].foodAmount << " " << rlist[i].foodUnit
<< " " << rlist[i].foodPrice << " " << rlist[i].eachPrice << " " << rlist[i].updateTime
<< " " << rlist[i].totalPrice << endl;
}
pfs.close();
}
//管理员菜单
void menu()
{
string sel = "0";
system("cls");
cout << "\t\t\t*********欢迎来到小超市食品管理系统*********" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 1 显示库存及销售记录 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 2 添加库存食品 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 3 删除库存食品 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 4 修改库存食品 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 5 查询库存食品 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 6 库存食品排序 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 7 食品销售 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 8 清空系统数据 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t| 0 退出 |" << endl;
cout << "\t\t\t|------------------------------------------|" << endl;
cout << "\t\t\t请选择【0-8】:";
cin >> sel;
while(sel != "0" && sel != "1" && sel != "2" && sel != "3" && sel != "4" && sel != "5" && sel != "6" && sel != "7" && sel != "8")
{
cout << "\t\t\t输入不合法,请重新选择【0-8】:";
cin >> sel;
}
if(sel == "1")
{
this->display(); //显示库存
this->menu();
}
else if(sel == "2")
{
this->insertFood();
this->menu();
}
else if(sel == "3")
{
this->deleteFood();
this->menu();
}
else if(sel == "4")
{
this->updateFood();
this->menu();
}
else if(sel == "5")
{
this->selectFood();
this->menu();
}
else if(sel == "6")
{
this->sortFood();
this->menu();
}
else if(sel == "7")
{
this->sellFood();
this->menu();
}
else if(sel == "8")
{
this->clearSystem();
this->menu();
}
else if(sel == "0")
{
exit(0);
}
}
//遍历食品容器 clist
void traverseFood()
{
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
Food::showHeader();
cout << "\t\t-------------------------------------------" << endl;
for (int i = 0; i < flist.size(); i++)
{
cout << "\t\t";
flist[i].showFdInfo();
}
cout << "\t\t-------------------------------------------" << endl;
}
//遍历记录容器 rlist
void traverseRecord()
{
cout << "\t\t------------------------------------------------------------------" << endl;
cout<<"\t\t";
Record::showHeader();
cout << "\t\t------------------------------------------------------------------" << endl;
for (int i = 0; i < rlist.size(); i++)
{
cout << "\t\t";
rlist[i].showRecInfo();
}
cout << "\t\t------------------------------------------------------------------" << endl;
}

//显示信息列表 包含库存和历史操作记录
void display()
{
system("cls");
cout << "\t\t********************欢迎来到显示信息列表功能**********************" << endl;
cout << "\t\t表1:超市库存信息表"<<endl;
this->traverseFood();
cout<<"\t\t食品种类数量(注意:此处按名称细分):"<<flist.size()<<"种"<<endl;
cout << "\n\t\t表2:销售记录信息表"<<endl;
this->traverseRecord();
if(rlist.size() == 0)
{
cout<<"\t\t当前销售总额: ¥0"<<endl;
}
else
{
cout<<"\t\t当前销售总额: ¥"<< rlist.back().totalPrice << endl;
}
cout << "\n\t\t";
system("pause");
}
//添加库存食品
void insertFood()
{
while(true)
{
system("cls");
cout << "\t\t*****************欢迎来到添加库存食品功能*********************" << endl;
//显示当前库存信息
cout<< "\t\t当前库存:"<<endl;
traverseFood();
cout<<endl;
cout << "\t\t------------------" << endl;
cout << "\t\t1 添加库存食品" << endl;
cout << "\t\t2 返回主菜单" << endl;
cout << "\t\t------------------" << endl;
cout << "\t\t请选择【1-2】:";
string sel;
cin >> sel;
while(sel != "1" && sel != "2")
{
cout << "\t\t输入不合法,请重新输入【1-2】:";
cin >> sel;
}
if(sel == "1")
{
string flag = "1";
while (flag == "1")
{
Food f;
cout << "\t\t输入添加的食品信息:"<<endl;
cout << "\t\t食品名称:";
cin >> f.foodName;
bool check = false;
for(int i = 0; i < flist.size(); ++i)
{
if(f.foodName == flist[i].foodName)
{
cout<<"\t\t系统中已存在该食品,如要添加该食品库存,请通过修改功能直接修改此食品库存!"<<endl;
check = true;
break;
}
}
if(check) break;
cout<<"\t\t添加数量:";
cin>>f.foodAmount;
cout<<"\t\t食品单位:";
cin>>f.foodUnit;
cout<<"\t\t食品种类:";
cin>>f.foodKind;
flist.push_back(f);
writeFile();
cout << "\n\t\t添加成功!是否继续添加?(1 是 0 否)" << endl;
cout << "\t\t请进行选择【0-1】:";
cin >> flag;
while(flag != "0" && flag != "1")
{
cout << "\t\t输入不合法,请重新选择【0-1】:";
cin >> flag;
}
}
cout << "\t\t";
system("pause");
}
else
{
break;
}
}
}

//删除库存食品
void deleteFood()
{
while (true)
{
system("cls");
cout << "\t\t*********************欢迎来到删除库存食品功能*********************" << endl;
cout << "\t\t当前库存:"<<endl;
traverseFood();
cout << endl;
string sel = "0";
cout << "\t\t-----------------" << endl;
cout << "\t\t1 按食品名称删除" << endl;
cout << "\t\t2 返回主菜单" << endl;
cout << "\t\t-----------------" << endl;
cout << "\t\t请进行选择【1-2】:";
cin >> sel;
while(sel != "1" && sel != "2")
{
cout << "\t\t输入不合法,请重新选择【1-2】:";
cin >> sel;
}
if (sel == "1")
{
string keyName;
bool flag = false;
cout << "\t\t请输入待删除食品的名称:";
cin >> keyName;
for (vector<Food>::iterator it = flist.begin(); it != flist.end(); ++it)
{
if (it->foodName == keyName)
{
flag = true;
cout << "\t\t待删除食品的库存信息如下:" << endl;
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
Food::showHeader();
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
it->showFdInfo();
cout << "\t\t-------------------------------------------" << endl;

cout << "\t\t确认删除?(1 是 0 否)" << endl;
cout << "\t\t请进行选择【0-1】:";
string ch = "0";
cin >> ch;

while(ch != "0" && ch != "1")
{
cout << "\t\t输入不合法,请重新选择【0-1】:";
cin >> ch;
}
if (ch == "0") break;
else
{
flist.erase(it);
writeFile();
cout << "\t\t删除成功!" << endl;
break;
}
}
}
if (!flag) cout << "\t\t超市中没有此类食品,无法删除!\n" << endl;
cout << "\t\t";
system("pause");
}
else
{
break;
}
}
}

//修改食品库存信息
void updateFood()
{
while(true)
{
system("cls");
cout << "\t\t******************欢迎来到修改食品库存信息功能******************" << endl;
cout << "\t\t当前库存:"<<endl;
traverseFood();
cout << endl;
string sel = "0";
cout << "\t\t--------------------" << endl;
cout << "\t\t1 按食品名称修改库存" << endl;
cout << "\t\t2 返回主菜单" << endl;
cout << "\t\t--------------------" << endl;
cout << "\t\t请进行选择【1-2】:";
cin >> sel;
while(sel != "1" && sel != "2" )
{
cout << "\t\t输入不合法,请重新选择【1-2】:";
cin >> sel;
}
if(sel == "1")
{
bool flag = false;
string keyName;
cout << "\t\t请输入待修改库存的食品名称:";
cin >> keyName;
for(int i = 0; i < flist.size(); i++)
{
if (flist[i].foodName == keyName)
{
flag = true;
cout << "\t\t待修改食品的库存信息如下:" << endl;
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
Food::showHeader();
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
flist[i].showFdInfo();
cout << "\t\t-------------------------------------------" << endl;
Food f;
f.foodName = flist[i].foodName;
cout << "\t\t请输入修改后的食品库存量:";
cin>> f.foodAmount;
cout << "\t\t请输入修改后的食品单位:";
cin >> f.foodUnit;
cout << "\t\t请输入修改后的食品种类:";
cin >> f.foodKind;
cout << "\t\t是否确认修改?(1 是 0 否)" << endl;
cout << "\t\t请进行选择【0-1】:";
string ch = "0";
cin >> ch;
while(ch != "0" && ch != "1")
{
cout << "\t\t输入不合法,请重新选择【0-1】:";
cin >> ch;
}

if (ch == "0") break;
else
{
flist[i] = f;
}
writeFile();
cout << "\t\t修改成功!" << endl;
break;
}
}
if (!flag) cout << "\t\t无法查询到此线路,无法修改!\n" << endl;
cout<<"\t\t";
system("pause");
}
else
{
break;
}
}
}

// 查询食品库存信息
void selectFood()
{
while (true)
{
system("cls");
cout << "\t\t****************欢迎来到查询食品库存信息功能******************" << endl;
cout << "\t\t-----------------" << endl;
cout << "\t\t1 按食品名称查询" << endl;
cout << "\t\t2 按食品种类查询" << endl;
cout << "\t\t3 返回主菜单" << endl;
cout << "\t\t-----------------" << endl;
cout << "\t\t请进行选择【1-3】:";
string sel = "0";
cin >> sel;
while(sel != "1" && sel != "2" && sel != "3")
{
cout << "\t\t输入不合法,请重新选择【1-3】:";
cin >> sel;
}
if (sel == "1")
{
string keyName;
bool flag = false;
cout << "\t\t请输入待查询食品的名称:";
cin >> keyName;
cout << "\t\t查询结果如下:" << endl;
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
Food::showHeader();
cout << "\t\t-------------------------------------------" << endl;
for (int i = 0; i < flist.size(); i++)
{
if (flist[i].foodName == keyName)
{
flag = true;
cout<<"\t\t";
flist[i].showFdInfo();
cout << "\t\t-------------------------------------------" << endl;
break;
}
}
if (!flag) cout << "\t\t超市中不存在此种食品!\n" << endl;
cout << "\t\t";
system("pause");
}
else if (sel == "2")
{
string keyKind;
bool flag = false;
cout << "\t\t请输入待查询食品的种类:";
cin >> keyKind;
cout << "\t\t查询结果如下:" << endl;
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
Food::showHeader();
cout << "\t\t-------------------------------------------" << endl;
for (int i = 0; i < flist.size(); i++)
{
if (flist[i].foodKind == keyKind)
{
flag = true;
cout<<"\t\t";
flist[i].showFdInfo();
}
}
cout << "\t\t-------------------------------------------" << endl;
if (!flag) cout << "\t\t超市中不存在此类食品!\n" << endl;
cout << "\t\t";
system("pause");
}
else
{
break;
}
}
}
//将食品列表按食品名称字典序升序排列
static bool cmp(const Food& f1,const Food& f2)
{
return f1.foodName < f2.foodName;
}
void sortFood()
{
while(true)
{
system("cls");
cout << "\t\t******************欢迎来到食品排序功能*********************" << endl;
cout<<"\t\t库存信息表:"<<endl;
traverseFood();
cout<<endl;
string sel;
cout << "\t\t-----------------" << endl;
cout << "\t\t1 按食品名称字典序排序" << endl;
cout << "\t\t2 返回主菜单" << endl;
cout << "\t\t-----------------" << endl;
cout << "\t\t请进行选择【1-2】:";
cin >> sel;
while(sel != "1" && sel != "2")
{
cout << "\t\t输入不合法,请重新选择【1-2】:";
cin >> sel;
}
if(sel == "1")
{
sort(flist.begin(), flist.end(), cmp);
cout<<"\t\t排序成功!"<<endl;
cout<<"\t\t";
system("pause");
}
else
{
break;
}

}
}


//售货 即添加元素到rlist中 从clist中 删除元素
void sellFood()
{
while (true)
{
system("cls");
cout << "\t\t*******************欢迎来到食品销售功能***********************" << endl;
//显示当前库存信息
cout<< "\t\t超市当前库存:"<<endl;
traverseFood();
cout<<endl;
string sel = "0";
cout << "\t\t-----------------" << endl;
cout << "\t\t1 销售食品" << endl;
cout << "\t\t2 返回主菜单" << endl;
cout << "\t\t-----------------" << endl;
cout << "\t\t请进行选择【1-2】:";
cin >> sel;
while(sel != "1" && sel != "2")
{
cout << "\t\t输入不合法,请重新选择【1-2】:";
cin >> sel;
}
if(sel == "1")
{
string keyName;
bool flag = false;
cout << "\t\t请输入待售食品的名称:";
cin >> keyName;
for (vector<Food>::iterator it = flist.begin(); it != flist.end(); ++it)
{
if (it->foodName == keyName)
{
flag = true;
cout << "\t\t"<< it->foodName << "的当前库存如下:" << endl;
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
Food::showHeader();
cout << "\t\t-------------------------------------------" << endl;
cout<<"\t\t";
it->showFdInfo();
cout << "\t\t-------------------------------------------" << endl;
cout << "\t\t确认进行销售?(1 是 0 否)" << endl;
cout << "\t\t请进行选择【0-1】:";
string ch = "0";
cin >> ch;
while(ch != "0" && ch != "1")
{
cout << "\t\t输入不合法,请重新选择【0-1】:";
cin >> ch;
}
if (ch == "0") break;
else
{
Record r;
r.foodName = it->foodName;
r.foodUnit = it->foodUnit;
cout<<"\t\t请输入销售数量:";
cin>>r.foodAmount;
while(r.foodAmount > it->foodAmount)
{
cout<<"\t\t已超出库存数量,请重新输入:";
cin>>r.foodAmount;
}
cout<<"\t\t请输入售出单价:";
cin>>r.foodPrice;
r.eachPrice = r.foodPrice * r.foodAmount;
r.updateTime = Tool::getTime();
if(rlist.size() == 0)
{
r.totalPrice = r.foodPrice * r.foodAmount;
}
else
{
r.totalPrice = rlist.back().totalPrice + r.foodPrice * r.foodAmount;
}
if(r.foodAmount == it->foodAmount)
{
flist.erase(it);
}
else
{
it->foodAmount -= r.foodAmount;
}
rlist.push_back(r);
writeFile();
cout << "\t\t销售成功!" << endl;
break;
}
}
}
if (!flag) cout << "\t\t本超市中没有此类食品,无法销售!\n" << endl;
cout << "\t\t";
system("pause");
}
else
{
break;
}
}
}

//清空系统数据
void clearSystem()
{
while (true)
{
string sel = "0";
system("cls");
cout << "\t\t******************欢迎来到清空系统数据功能*******************" << endl;
cout << "\t\t------------------" << endl;
cout << "\t\t1 确认清空系统数据" << endl;
cout << "\t\t2 返回主菜单" << endl;
cout << "\t\t------------------" << endl;
cout << "\t\t请慎重选择【1-2】:";
cin >> sel;
while(sel != "1" && sel != "2")
{
cout << "\t\t输入不合法,请重新输入【1-2】:";
cin >> sel;
}
if (sel == "1")
{
flist.clear();
rlist.clear();
cout << "\t\t清空成功!" << endl;
cout << "\t\t";
system("pause");
writeFile();
}
else
{
break;
}
}
}
};

int main()
{
FoodSystem fs;
fs.init();
fs.menu();
return 0;
}

运行方法

  1. 新建一个cpp文件,命名为”main.cpp”。
  2. 将系统完整代码复制粘贴至”main.cpp”中。
  3. 利用Dev C++运行”main.cpp”即可。