服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - C/C++ - C++实现图书管理系统简易版

C++实现图书管理系统简易版

2022-10-19 13:30阿白i C/C++

这篇文章主要为大家详细介绍了C++实现图书管理系统简易版,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了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
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
#include<iostream>
#include<string>
#include<string.h>
#include<cstdio>
#include<conio.h>
#include<fstream>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<regex>
#include<windows.h>
#include<sstream>//stringstream要使用到的头文件
#define STUDENT_FILE "student_text.txt"
#define BOOK_FILE "book_text.txt"
#define CLASS_FILE "class.txt"
#define MAX 1000
#define MIN 100
using namespace std;
class Student;
class Book;
class Clazz;
void initialize();//初始化
void Manager_Menu();
void Student_Menu();
void existSystem();  //退出图书管理系统
 
void show_book_base();
string input_password();//不可见输入密码
int student_id_exist(int id);//查找用户是否存在
int manager_id_exist(int id);
int book_id_exist(int id);//查找书籍是否存在
int class_id_exist(int id);
int random_id(); //产生随机图书编号
void book_find();
void load_information();
void update_information();
void regist_windows();
void regist_manager();
void regist_student();
bool student_cmp(Student a, Student b);
bool class_cmp(Clazz a, Clazz b);
bool book_cmp(Book a, Book b);
class Book
{
    int book_id;                    //书籍编号
    string book_name;               //书籍名称
    int book_total_num;             //该类书籍总数
    string book_author;             //书籍作者
    string book_type;               //书籍分类
    string book_present;            //书籍简介
    int book_student_len;           //每种书共有几人选
    int student_id[MIN];       //借阅该书籍的学生学号
    string student_name[MIN];  //借阅该书籍的学生姓名
public:
    Book()
    {
        book_id = -1;
        book_total_num = 0;
        book_student_len = 0;
        book_type = "";
        book_present = "";
        memset(student_id, 0, MIN);
        for (int i = 0; i < MIN; i++)
        {
            student_name[i] = "";
        }
    }
    void set_book_name(string book_name)
    {
        this->book_name = book_name;
    }
    void set_book_author(string book_author)
    {
        this->book_author = book_author;
    }
    void set_book_type(string book_type)
    {
        this->book_type = book_type;
    }
    void set_book_total_num(int book_total_num)
    {
        this->book_total_num = book_total_num;
    }
    void set_book_id(int book_id)
    {
        this->book_id = book_id;
    }
    int get_book_id()
    {
        return book_id;
    }
    void set_book_information(int book_id, string book_name, int book_total_num, string book_author, string book_type)
    {
        set_book_id(book_id);
        set_book_name(book_name);
        set_book_author(book_author);
        set_book_type(book_type);
        set_book_total_num(book_total_num);
        //set_book_present(book_present);
    }
    void set_book_present(string book_present)
    {
        this->book_present = book_present;
    }
    string& get_book_present()
    {
        return book_present;
    }
    void show_book_information();
    friend int book_id_exist(int id);
    friend void show_book_base();
    friend class Student;
    friend class Manager;
    friend void initialize();
    friend void load_information();
    friend void update_information();
};
Book book[MAX];
int book_len = 0;
class User
{
protected:
    int id;
    string name;
    string password;
    int mark;
public:
    User()
    {
        id = -1;
        mark = 0;
        name = "";
        password = "";
    }
    void password_update();
    virtual void book_insert()=0;
    virtual void book_delete()=0;
    friend void initialize();
    void set_id(int id)
    {
        this->id = id;
    }
    void set_name(string name)
    {
        this->name = name;
    }
    void set_mark(int mark)
    {
        this->mark = mark;
    }
    void set_password(string password)
    {
        this->password = password;
    }
    int get_id()
    {
        return  id;
    }
    int get_mark()
    {
        return this->mark;
    }
    string get_name()
    {
        return name;
    }
    string get_password()
    {
        return password;
    }
};
class Student:public User
{
    int student_grade;    //入学年份--年级
    int class_id;
    string student_gender;
    int student_book_len;//借阅书籍总数
public:
    Student()
    {
        id = -1;  //id为-1时表示该账户无效
        class_id = -1;
        name = "";
        student_gender = "";
        student_grade = -1;
        student_book_len = 0;
    }
    Student operator = (const Student& p);
    void set_class_id(int id)
    {
        class_id = id;
    }
    void set_student_grade(int student_grade)
    {
        this->student_grade = student_grade;
    }
    void set_student_gender(string student_gender)
    {
        this->student_gender = student_gender;
    }
    int get_class_id()
    {
        return class_id;
    }
    int get_student_grade()
    {
        return student_grade;
    }
    string get_student_gender()
    {
        return  student_gender;
    }
    
    //学生
    void book_insert();
    void student_information_view();
    void book_delete();
    void student_information_update();
    //学生修改账号密码
    
    void show_self();
    void student_windows();
 
    friend void eroll_windows();
 
    friend class Manager;
    friend void load_information();
    friend void update_information();
    friend bool student_cmp(Student a,Student b);
};
Student student[MAX];
int student_len = 0;
class Manager :public User
{
public:
    Manager()
    {
        id = -1;
        mark = 0;
        name = "";
        password = "";
    }
    Manager(int id,int mark,string name,string password)
    {
        this->id =id;
        this->mark = mark;
        this->name = name;
        this->password = password;
    }
    Manager operator = (const Manager& p);
    //管理员对学生账号的管理
    void student_insert();
    void student_delete();
    void student_view();
 
    //管理员对书籍的管理
    void book_insert();
    void book_delete();
    void book_view();
    void book_update();
    //班级
    void class_insert();
    void class_update();
    void class_view();
    void class_delete();
    void manager_windows();
    void manager_insert();
    
    friend void load_information();
    friend void update_information();
};
Manager manager[MIN];
int manager_len = 0;
class Clazz
{
    int class_id;
    string class_name;
    string teacher_name;
    int student_len;
public:
    Clazz()
    {
        class_id = -1;
        class_name = "";
        teacher_name = "";
        student_len = 0;
    }
    int get_class_id()
    {
        return class_id;
    }
    string get_class_name()
    {
        return class_name;
    }
    string get_teacher_name()
    {
        return teacher_name;
    }
    void set_class_id(int id)
    {
        this->class_id =id;
    }
    void set_class_name(string name)
    {
        this->class_name = name;
    }
    void set_teacher_name(string name)
    {
        this->teacher_name = name;
    }
    
    friend int class_id_exist(int id);
    friend void load_information();
    friend void update_information();
};
Clazz clazz[MIN];
int class_len = 0;
 
int main()
{
    initialize();
    //登录
    regist_windows();
    system("pause");
    return 0;
}
 
void initialize()
{
    system("title 图书信息管理系统");
    system("color f0");
    system("mode con cols=90 lines=38");
    srand((int)time(0));
 
    load_information();
    Manager p1;
    p1.set_id(111111);
    p1.set_name("张晖");
    p1.set_password("111111");
    manager[0]=p1; manager_len++;
    Manager p2(222222,1, "李四", "222222");
    manager[1]=p2; manager_len++;
}
void Manager_Menu()
{
 
    cout << " ________________________________________________________________________________________" << endl;
    cout << " |                             图书管理管理系统                                         |" << endl;
    cout << " |______________________________________________________________________________________|" << endl;
    cout << " |              1.增加学生信息              |              13.修改登录密码              |" << endl;
    cout << " |              2.查看学生信息              |              14.退出当前账号              |" << endl;
    cout << " |              3.删除学生信息              |              0.退出管理系统               |" << endl;
    cout << " |__________________________________________|___________________________________________|" << endl;
    cout << " |              4.增加书籍信息              |              8.增加班级信息               |" << endl;
    cout << " |              5.查看书籍信息              |              9.查看班级信息               |" << endl;
    cout << " |              6.修改书籍信息              |              10.修改班级信息              |" << endl;
    cout << " |              7.删除书籍信息              |              11.删除班级信息              |" << endl;
    cout << " |                                          |              12.增加管理员                |" << endl;
    cout << " |__________________________________________|___________________________________________|" << endl;
    cout << endl;
}
void Student_Menu()
{
    cout << "           ______________________________________________" << endl;
    cout << "           |                学生图书系统                |" << endl;
    cout << "           |____________________________________________|" << endl;
    cout << "           |               1.选择借阅书籍               |" << endl;
    cout << "           |               2.查找书籍信息               |" << endl;
    cout << "           |               3.归还借阅书籍               |" << endl;
    cout << "           |               4.查询个人信息               |" << endl;
    cout << "           |____________________________________________|" << endl;
    cout << "           |               5.修改个人信息               |" << endl;
    cout << "           |               6.修改登录密码               |" << endl;
    cout << "           |               7.退出当前账号               |" << endl;
    cout << "           |               0.退出管理系统               |" << endl;
    cout << "           |____________________________________________|" << endl;
    cout << endl;
}
void Manager::manager_windows()
{
    while (true)
    {
        int choice = 0;
        Manager_Menu();
        cout << "\t\t请输入您的选择:" << endl;
        cout << "          ";
        cin >> choice;
        switch (choice)
        {
        case 0://退出
        {
            existSystem();
            break;
        }
        case 1://添加
        {
            student_insert();
            break;
        }
        case 2://显示
        {
            student_view();
            break;
        }
        case 3://删除
        {
            student_delete();
            break;
        }
        case 4:
        {
            book_insert();
            break;
        }
        case 5:
        {
            book_view();//book_find();
            break;
        }
        case 6://查找
        {
            book_update();
            break;
        }
        case 7:
        {
            book_delete();
            break;
        }
        case 8:
        {
            class_insert();
            break;
        }
        case 9:
        {
            class_view();
            break;
        }
        case 10://查找
        {
            class_update();
            break;
        }
        case 11:
        {
            class_delete();
            break;
        }
        case 12:
        {
            manager_insert();
            break;
        }
        case 13:
        {
            password_update();
            break;
        }
        case 14://回到登录界面
        {
            system("cls");
            update_information();
            regist_windows();
            break;
        }
        default:
        {
            cout << "没有该选项!" << endl;
            system("cls");
            break;
        }
        }
    }
}
void Student::student_windows()
{
 
    while (true)
    {
        int choice = 0;
        Student_Menu();
        cout << "\t\t请输入您的选择:" << endl;
        cout << "         ";
        cin >> choice;
        switch (choice)
        {
        case 0://退出
        {
            existSystem();
            break;
        }
        case 1://添加
        {
            book_insert();
            break;
        }
        case 2:
        {
            book_find();
            break;
        }
        case 3:
        {
            book_delete();
            break;
        }
        case 4:
        {
            student_information_view();
            break;
        }
        case 5:
        {
            student_information_update();
            break;
        }
        case 6:
        {
            password_update();
            break;
        }
        case 7://回到登录界面
        {
            system("cls");
            update_information();
            regist_windows();
            break;
        }
        default:
        {
            cout << "没有该选项" << endl;
            system("cls");
            break;
        }
        }
    }
}
void regist_windows()
{
    int select = 0;
    cout << "\t\t1.管理员登录" << endl;
    cout << "\t\t2.学生登录" << endl;
    cin >> select;
    system("cls");
    if (select == 1)
    {
        regist_manager();
    }
    else if (select == 2)
    {
        regist_student();
    }
    else
    {
        cout << "该选项不存在!请选择1或2!" << endl;
    }
}
void regist_manager()
{
    cout << "\t用户名:";
    int temp_user_id = -1; cin >> temp_user_id; cout << endl;
    cout << "\t密码:";
    string temp_password;  temp_password = input_password();
    int flag = 0;
    int position = manager_id_exist(temp_user_id);
    if (position == -1)
    {
        cout << "该用户不存在!" << endl;
        regist_manager();
 
    }
    else if (manager[position].get_password() == temp_password)
    {
        system("cls");
        while (true)
        {
            manager[position].manager_windows();
        }
    }
    else
    {
        cout << "\t\t用户名或密码错误" << endl << endl;
        regist_manager();
    }
    system("pause");
    system("cls");
}
void regist_student()
{
    int temp_user_id = 0;
    string temp_password;
    cout << "\t用户名:";
    cin >> temp_user_id;
    cout << endl;
    cout << "\t密码:";
    temp_password = input_password();
    int flag = 0;
    int position = student_id_exist(temp_user_id);
    if (position == -1)
    {
        cout << "\t该用户不存在!" << endl;
        regist_student();
    }
    else if (student[position].get_password() == temp_password)
    {
        system("cls");
        while (true)
        {
            student[position].student_windows();
        }
    }
    else
    {
        cout << "\t\t用户名或密码错误" << endl << endl;
        regist_student();
    }
    system("pause");
    system("cls");
}
void Book::show_book_information()
{
    cout << "-------------------------------------------------------------------------------------\n";
    cout << " 书名\t\t\t类型\t\t\t\t作者\n";
    cout << book_name << "\t\t\t" << book_type << "\t\t\t" << book_author << endl;
    cout << "-------------------------------------------------------------------------------------\n";
    cout << " 总数\t\t\t剩余量\n";
    cout << book_total_num << "\t\t\t" << (book_total_num - book_student_len) << endl;
    cout << "-------------------------------------------------------------------------------------\n";
    cout << "\t\t\t小说简介\n";
    cout << book_present << endl;
    cout << "-------------------------------------------------------------------------------------\n";
}
void User::password_update()
{
    int flag = 0;
    while (true)
    {
        cout << "请输入旧密码:";
        string last_password, new_password1, new_password2;
        last_password = input_password();
        if (last_password == password)
        {
            cout << "请输入新密码(大于等于6位):"; new_password1 = input_password();
            cout << "请再次输入新密码:";         new_password2 = input_password();
            if (new_password1 == new_password2)
            {
                if ((new_password1.size() >= 6) && (new_password1.size() <= 13))
                {
                    this->password = new_password1;
                    cout << "密码修改成功!" << endl;
                    break;
                }
                else
                {
                    cout << "密码应大于等于6位!修改失败!" << endl;
                }
            }
            else
            {
                cout << "两次密码不一致!请重新输入!" << endl;
            }
        }
        else
        {
            flag++;
            if (flag <= 3)
            {
                cout << "旧密码错误!" << endl;
            }
            else
            {
                cout << "密码多次输入错误!返回菜单界面!";
                break;
            }
        }
    }
    system("pause");
    system("cls");
}
 
Manager  Manager::operator = (const Manager& p)
{
    this->id = p.id;
    this->mark = p.mark;
    this->name = p.name;
    this->password = p.password;
    return *this;
}
void Manager::student_insert()
{
    if (student_len > MAX)
    {
        cout << "信息系统已满,无法添加!" << endl;
        return;
    }
    else
    {
        Student temp_student;
        cout << "请输入学号:" << endl;
        int temp_id; cin >> temp_id;
        cout << "请输入姓名:" << endl;
        string temp_name; cin >> temp_name;
        cout << "请输入权限:" << endl;
        cout << "1.普通用户权限" << endl;
        cout << "2.高级用户权限" << endl;
        int temp_mark; cin >> temp_mark;
        temp_student.set_mark(temp_mark);
        string temp_student_gender;
        while (true)
        {
            cout << "请选择性别:" << endl;
            cout << "1.女\n2.男\n";
            int choice = 0; cin >> choice;
            if (choice == 1)
            {
                temp_student_gender = "女"; break;
            }
            else if (choice == 2)
            {
                temp_student_gender = "男"; break;
            }
            else
            {
                cout << "没有该选项!请重新选择!\n";
            }
        }
        int temp_student_grade;
        while (true)
        {
            cout << "请输入年级(入学年份):" << endl;
            cout << "1.2018\n2.2019\n3.2020\n4.2021\n";
            int choice = 0; cin >> choice;
            if (choice == 1)
            {
                temp_student_grade = 2018; break;
            }
            else if (choice == 2)
            {
                temp_student_grade = 2019; break;
            }
            else if (choice == 3)
            {
                temp_student_grade = 2020; break;
            }
            else if (choice == 2)
            {
                temp_student_grade = 2021; break;
            }
            else
            {
                cout << "没有该选项!请重新选择!\n";
            }
        }
        cout << "\t\t班级信息如下\n";
        for (int i = 0; i < class_len; i++)
            cout << clazz[i].get_class_id() << "\t\t" << clazz[i].get_class_name() << endl;
        while (1)
        {
            cout << "请输入班级编号\n";
            int temp_id = 0; cin >> temp_id;
            if (class_id_exist(temp_id) != -1)
            {
                temp_student.set_class_id(temp_id);
                break;
            }
            else
            {
                cout << "该班级编号不存在!\n";
            }
        }
 
        string temp_password;
        stringstream transform;
        transform << temp_id; transform >> temp_password;
        temp_student.set_password(temp_password);
        temp_student.set_id(temp_id);
        temp_student.set_student_grade(temp_student_grade);
        temp_student.set_name(temp_name);
        temp_student.set_student_gender(temp_student_gender);
        student[student_len] = temp_student;
       /* while (1)
        {
            cout << "请设置您的密码:" << endl;
            temp_password1 = input_password();
            temp_password2 = input_password();
            if (temp_password1 == temp_password2)
            {
                student[student_len].password = temp_password1;
                student_len++;
                break;
            }
            else
            {
                cout << "两次密码不一致!请重新设置密码!" << endl;
            }
        }*/
        student_len++;
        cout << "学生信息添加成功!" << endl;
        sort(student, student + student_len, student_cmp);
    }
    system("pause");
    system("cls");
}
void Manager::student_view()
{
    cout << "\t\t1.查询单个账号信息" << endl;
    cout << "\t\t2.查看所有账号信息" << endl;
    int choice; cin >> choice;
    if (choice == 1)
    {
        cout << "\t\t请输入查询账号:" << endl;
        int id; cin >> id;
        int pos = student_id_exist(id);
        if (pos == -1)
        {
            cout << "\t\t该账号不存在!" << endl;
        }
        else
        {
            student[pos].show_self();
        }
    }
    else
    {
        if (student_len == 0)
        {
            cout << "当前记录为空" << endl;
        }
        else
        {
            cout << "序号:\t姓名:\t学号: \t年级: \t性别\n";
            for (int i = 0; i < student_len; i++)
            {
                cout << i + 1 << "\t\t";
                cout << student[i].name << "\t\t" << student[i].id << "\t\t";
                if (student[i].student_book_len == 0)
                {
                    cout << "未借阅书籍";
                }
                else
                {
                    for (int j = 0; j < book_len; j++)
                    {
                        for (int k = 0; k < book[j].book_total_num; k++)
                        {
                            if (book[j].student_name[k] == student[i].name)
                                cout << book[j].book_id << "\t\t" << book[j].book_name << endl;;
                        }
                    }
                }
                cout << endl;
            }
        }
    }
    system("pause");
    system("cls");
}
void Manager::student_delete()
{
    cout << "请输入您要删除的学生账号:" << endl;
    int temp_id;
    cin >> temp_id;
    int position = student_id_exist(temp_id);
    if (position != -1)
    {
        for (int i = position; i < student_len - 1; i++)
        {
            student[i] = student[i + 1];
        }
        student_len--;
        cout << "删除成功" << endl;
    }
    else
    {
        cout << "该学生账号不存在!" << endl;
    }
    system("pause");
    system("cls");
}
void Manager::book_insert()
{
    int temp_book_id;
    string temp_book_name;
    show_book_base();
    //cout << "请输入想增加的书籍编号:" << endl;
    cout << "书籍编号由系统自动生成!" << endl;
    temp_book_id = random_id();
    cout << "请输入想增加的书籍名称:" << endl;
    cin >> temp_book_name;
    cout << "请输入书籍数量:" << endl;
    int temp_book_len; cin >> temp_book_len;
    cout << "请输入书籍作者:" << endl;
    string temp_book_author; cin >> temp_book_author;
    cout << "请输入书籍分类:" << endl;
    string temp_book_type; cin >> temp_book_type;
    cout << "请输入书籍简介:" << endl;
    string temp_book_present; cin >> temp_book_present;
    book[book_len].set_book_information(temp_book_id, temp_book_name, temp_book_len, temp_book_author, temp_book_type);
    book[book_len].set_book_present(temp_book_present);
    book_len++;
    cout << "书籍信息添加成功!" << endl;
    sort(book, book + book_len, book_cmp);
    system("pause");
    system("cls");
}
void Manager::book_delete()
{
    int temp_book_id;
    show_book_base();
    cout << "请输入想删除的书籍id号:" << endl;
    cin >> temp_book_id;
    if (book_id_exist(temp_book_id) == -1)
    {
        cout << "该书籍不存在!" << endl;
    }
    else
    {
        for (int i = 0; i < book_len - 1; i++)
        {
            book[i] = book[i + 1];
        }
        book_len--;
        cout << "书籍信息删除成功!" << endl;
    }
    system("pause");
    system("cls");
}
void Manager::book_update()
{
    show_book_base();
    cout << "请输入想修改的书籍编号:" << endl;
    int temp_book_id;  cin >> temp_book_id;
    cout << "请选择你要修改的书籍信息" << endl;
    cout << "1--修改书籍名称" << endl;
    cout << "2--修改书籍总数" << endl;
    cout << "3--修改书籍作者" << endl;
    cout << "4--修改书籍分类" << endl;
    cout << "5--修改书籍简介" << endl;
    cout << "0--返回菜单" << endl;
    int choice = 0; cin >> choice;
    switch (choice)
    {
    case 0: break;
    case 1:
    {
        cout << "请输入书籍名称:" << endl;
        string temp_book_name; cin >> temp_book_name;
        book[book_len].set_book_name(temp_book_name);
        cout << "修改成功\n";
        break;
    }
    case 2:
    {
        cout << "请输入书籍总数:" << endl;
        int temp_book_len; cin >> temp_book_len;
        book[book_len].set_book_total_num(temp_book_len);
        break;
    }
    case 3:
    {
        cout << "请输入书籍作者:" << endl;
        string temp_book_author; cin >> temp_book_author;
        book[book_len].set_book_author(temp_book_author);
        break;
    }
    case 4:
    {
        cout << "请输入书籍分类:" << endl;
        int temp_book_type; cin >> temp_book_type;
        book[book_len].book_type = temp_book_type;
        break;
    }case 5:
    {
        cout << "请输入书籍简介:" << endl;
        string temp_book_present; cin >> temp_book_present;
        book[book_len].book_present = temp_book_present;
        break;
    }
    default:
    {
        cout << "没有该选项!" << endl; break;
    }
    }
    system("pause");
    system("cls");
 
}
void Manager::book_view()
{
    if (book_len == 0)
    {
        cout << "无借阅信息!" << endl;
    }
    for (int i = 0; i < book_len; i++)
    {
        cout << "书籍id号:" << book[i].book_id << "\t书籍名:" << book[i].book_name
            << "\t作者:" << book[i].book_author
            << "\t书籍剩余数:" << (book[i].book_total_num - book[i].book_student_len)
            << "\t书籍总数:" << book[i].book_total_num << endl;
        if (book[i].book_student_len == 0)
        {
            cout << "\t\t空!" << endl;
        }
        else
        {
            cout << "学号\t\t" << "姓名" << endl;
            for (int j = 0; j < book[i].book_student_len; j++)
            {
                cout << book[j].book_id << "\t" << book[j].book_name << endl;
            }
        }
        cout << endl;
    }
    cout << "\t如果您需要查询书籍详细信息,请输入1;不需要则输入0\n";
    int ch = 0; cin >> ch;
    if (ch==1)
        book_find();
    system("pause");
    system("cls");
}
void Manager::class_insert()
{
    int temp_id;
    string temp_name;
    cout << "请输入想增加的班级编号:" << endl;
    cin >> temp_id;
    clazz[class_len].set_class_id(temp_id);
    cout << "请输入想增加的班级名称:" << endl;
    cin >> temp_name;
    clazz[class_len].set_class_name(temp_name);
    cout << "请输入想增加的班主任姓名:" << endl;
    string temp_teacher_name; cin >> temp_teacher_name;
    clazz[class_len].set_teacher_name(temp_teacher_name);
    class_len++;
    cout << "班级信息添加成功!" << endl;
    sort(clazz, clazz + class_len, class_cmp);
    system("pause");
    system("cls");
}
void Manager::class_delete()
{
    int temp_book_id;
    cout << "班级编号\t\t\t班级名称\n";
    for (int i = 0; i < book_len; i++)
        cout << clazz[i].get_class_id()<< "\t\t" << clazz[i].get_class_name () << endl;
    cout << "请输入想删除的班级编号:" << endl;
    cin >> temp_book_id;
    if (class_id_exist(temp_book_id) == -1)
    {
        cout << "该班级不存在!" << endl;
    }
    else
    {
        for (int i = 0; i < class_len - 1; i++)
        {
            clazz[i] = clazz[i + 1];
        }
        class_len--;
        cout << "班级信息删除成功!" << endl;
    }
    system("pause");
    system("cls");
}
void Manager::class_update()
{
    class_view();
    cout << "请输入想修改的班级编号:" << endl;
    int temp_book_id;  cin >> temp_book_id;
    cout << "请选择你要修改的班级信息" << endl;
    cout << "1--修改班级名称" << endl;
    cout << "2--修改班主任姓名" << endl;
    cout << "0--返回菜单" << endl;
    int choice = 0; cin >> choice;
    switch (choice)
    {
    case 0: break;
    case 1:
    {
        cout << "请输入班级名称:" << endl;
        string temp_name; cin >> temp_name;
        clazz[class_len].set_class_name(temp_name);
        cout << "修改成功\n";
        break;
    }
    case 2:
    {
        cout << "请输入班主任名称:" << endl;
        string temp_teacher_name; cin >> temp_teacher_name;
        clazz[class_len].set_teacher_name(temp_teacher_name);
        cout << "修改成功\n";
        break;
    }
    default:
    {
        cout << "没有该选项!" << endl; break;
    }
    }
    system("pause");
    system("cls");
 
}
void Manager::class_view()
{
    if (class_len == 0)
    {
        cout << "无班级信息!" << endl;
    }
    else
    {
        cout << "\t\t班级信息如下" << endl;
        cout << "班级编号\t\t班级名称\t\t班主任姓名" << endl;
        for (int i = 0; i < class_len; i++)
            cout << clazz[i].get_class_id() << setw(32) << clazz[i].get_class_name() << setw(26) << clazz[i].get_teacher_name() << endl;
    }
    system("pause");
    system("cls");
}
void Manager::manager_insert()
{
    if (this->mark == 0)
    {
        cout << "\t\t权限不足!" << endl;
    }
    else
    {
        cout << "请输入账号:" << endl;
        int temp_id; cin >> temp_id;
        cout << "请输入姓名:" << endl;
        string temp_name; cin >> temp_name;
        cout << "请输入权限:" << endl;
        cout << "1.普通管理员权限" << endl;
        cout << "2.高级管理员权限" << endl;
        int temp_mark; cin >> temp_mark;
        cout << "密码默认为账号!" << endl;
        string temp_password;
        stringstream transform;
        transform << temp_id; transform >> temp_password;
        Manager temp(temp_id, temp_mark, temp_name, temp_password);
        manager[manager_len] = temp;
        manager_len++;
    }
    system("pause");
    system("cls");
}
 
Student Student::operator = (const Student& p)
{
    this->id = p.id;
    this->name = p.name;
    this->student_gender = p.student_gender;
    this->student_grade = p.student_grade;
    this->class_id = p.class_id;
    this->student_book_len = p.student_book_len;
    this->password = p.password;
    return *this;
}
void Student::book_insert()
{
    cout << "可选书籍如下:" << endl;
    show_book_base();
    int temp_book_id;
    cout << "请输入你要借阅的书籍编号:" << endl;
    cin >> temp_book_id;
    int position = book_id_exist(temp_book_id);
    int count = book[position].book_student_len;
    if (position == -1)
    {
        cout << "该书籍不存在!" << endl;
    }
    else
    {
        book[position].student_id[count] = this->id;
        book[position].student_name[count] = this->name;
        book[position].book_student_len++;
        student_book_len++;
        cout << "借阅成功!" << endl;
    }
    system("pause");
    system("cls");
}
void Student::student_information_view()
{
    cout << "\t\t请输入查询账号:" << endl;
    int id; cin >> id;
    int pos =student_id_exist(id);
    if (pos != student_id_exist(id))
    {
        cout << "\t\t您无查看他人账号权限!" << endl;
    }
    else
    {
        show_self();
    }
    system("pause");
    system("cls");
}
void Student::student_information_update()
{
    cout << "请选择你要更改的信息:\n";
    cout << "1.修改性别\n";
    cout << "2.修改年级\n";
    cout << "3.修改班级\n";
    int choice; cin >> choice;
    if (choice == 1)
    {
        cout << "1.男\n2.女\n";
        int select; cin >> select;
        if (select == 1)
        {
            this->student_gender = "男";
            cout << "修改成功!\n";
        }
        else if (select == 1)
        {
            this->student_gender = "女";
            cout << "修改成功!\n";
        }
        else
            cout << "没有该选项!\n";
    }
    else if (choice == 2)
    {
        cout << "1.2018\n2.2019\n3.2020\n4.2021\n";
        int select; cin >> select;
        if (select == 1)
        {
            this->student_grade = 2018;
            cout << "修改成功!\n";
        }
        else if (select == 2)
        {
            this->student_grade = 2019;
            cout << "修改成功!\n";
        }
        else if (select == 3)
        {
            this->student_grade = 2020; cout << "修改成功!\n";
        }
        else if (select == 4)
        {
            this->student_grade = 2021; cout << "修改成功!\n";
        }
        else
            cout << "没有该选项!\n";
    }
    else if(choice == 3)
    {
        cout << "\t\t班级信息如下" << endl;
        cout << "班级编号\t\t班级名称\t\t班主任姓名" << endl;
        for (int i = 0; i < class_len; i++)
            cout << clazz[i].get_class_id() << "\t\t" << clazz[i].get_class_name() << "\t\t" << clazz[i].get_teacher_name() << endl;
        while (1)
        {
            cout << "\t\t请输入你选择的班级编号\n" << endl;
            int select; cin >> select;
            if (class_id_exist(select) != -1)
            {
                int temp_id; cin >> temp_id;
                this->class_id = temp_id;
                break;
            }
            else
            {
                cout << "\t\t该班级编号不存在!\n";
            }
        }
    }
    else
    {
        cout << "该选项不存在!\n";
    }
    system("pause");
    system("cls");
}
void Student::book_delete()
{
    cout << "您的已选书籍如下:" << endl;
    if (student_book_len == 0)
    {
        cout << "空!" << endl;
    }
    else
    {
        cout << "序号\t\t书籍名称\t\t书籍编号" << endl;;
        for (int i = 0; i < book_len; i++)
        {
            for (int j = 0; j < book[i].book_student_len; j++)
            {
                if (book[i].student_id[j] == this->id)
                {
                    cout << i + 1 << "\t\t" << book[i].book_name << "\t\t\t" << book[i].book_id << endl;
                }
            }
        }
    }
    cout << endl << "请输入您想退还的书籍编号:" << endl;
    int temp_book_id;  cin >> temp_book_id;
    int book_position = book_id_exist(temp_book_id);
    if (book_position == -1)
    {
        cout << "该书籍不存在!" << endl;
    }
    else
    {
        int student_position = -1;
        for (int i = 0; i < book[book_position].book_student_len; i++)
        {
            if (book[book_position].student_id[i] == id)
            {
                student_position = i;
                break;
            }
        }
        if (student_position != -1)
        {
            for (int i = student_position; i < book[book_position].book_student_len - 1; i++)
            {
                book[book_position].student_id[i] = book[book_position].student_id[i + 1];
                book[book_position].student_name[i] = book[book_position].student_name[i + 1];
            }
            book[book_position].book_student_len--;
            student_book_len--;
            cout << "书籍归还成功!" << endl;
        }
        else
        {
            cout << "你并未借阅过该书籍!" << endl;
        }
    }
    system("pause");
    system("cls");
}
void Student::show_self()
{
    cout << "\t\t账号信息如下:" << endl;
    cout << "______________________________________________________________________________\n";
    cout << " 姓名:" << this->name << "\t\t 学号:" << this->id << "\n";
    cout << "______________________________________________________________________________\n";
    cout << " 性别:" << this->student_gender << "\t\t 班级编号:" << this->class_id << "\n";
    cout << "______________________________________________________________________________\n";
    cout << " 书籍编号" << "\t\t书籍名称" << "\n";
    cout << "______________________________________________________________________________\n";
    if (this->student_book_len == 0)
    {
        cout << "\t\t暂未借阅书籍" << "\n";
    }
    else
    {
        for (int i = 0; i < book_len; i++)
        {
            for (int j = 0; j < book[i].book_student_len; j++)
            {
                if (book[i].student_id[j] == this->id)
                {
                    cout << "\t\t" << book[i].book_id
                        << "\t\t" << book[i].book_name << "\n";
                }
            }
        }
    }
    cout << "______________________________________________________________________________\n";
}
void book_find()
{
    cout << "请输入你要查找的书籍编号:" << endl;
    int temp_book_id; cin >> temp_book_id;
    int position = book_id_exist(temp_book_id);
    if (position == -1)
    {
        cout << "该书籍编号不存在!查找失败!" << endl;
    }
    else
    {
        book[position].show_book_information();
    }
    system("pause");
    system("cls");
}
void show_book_base()
{
    cout << "书籍id号:\t" << "书籍名称:" << endl;
    for (int i = 0; i < book_len; i++)
    {
        cout << book[i].book_id << "\t\t" << book[i].book_name << endl;
    }
}
int student_id_exist(int id)//二分查找
{
    int left = 0;
    int right = student_len;
    int mid = 0;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (id == student[mid].get_id())
            return mid;
        if (id > student[mid].get_id())
            left = mid + 1;
        else if (id < student[mid].get_id())
            right = mid;
    }
    return -1;
}
int manager_id_exist(int id)
{
    for (int i = 0; i < manager_len; i++)
    {
        if (manager[i].get_id() == id)
        {
            return i;
        }
    }
    return -1;
}
int book_id_exist(int id)
{
    int left = 0;
    int right = book_len;
    int mid = 0;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (id == book[mid].get_book_id())
            return mid;
        if (id > book[mid].get_book_id())
            left = mid + 1;
        else if (id < book[mid].get_book_id())
            right = mid;
    }
    return -1;
}
int class_id_exist(int id)
{
    int left = 0;
    int right = class_len;
    int mid = 0;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (id == clazz[mid].get_class_id())
            return mid;
        if (id > clazz[mid].get_class_id())
            left = mid + 1;
        else if (id < clazz[mid].get_class_id())
            right = mid;
    }
    return -1;
}
bool student_cmp(Student a, Student b)
{
    return  a.id < b.id;
}
bool class_cmp(Clazz a, Clazz b)
{
    return a.get_class_id() < b.get_class_id();
}
bool book_cmp(Book a, Book b)
{
    return a.get_book_id() < b.get_book_id();
}
void existSystem()
{
    cout << "欢迎下次使用" << endl;
    system("pause");
    exit(0);
}
int random_id() //产生随机书籍编号
{
    int id;
    for (int i = 0; i < 8; i++)
    {
        id = rand();
    }
    return id;
}
string input_password()
{
    char temp_password[20];
    int len = 0; char key;
    while ((key = _getch()) != '\r')//不可见输入
    {
        if (len < 12)
        {
            temp_password[len++] = key;
            putchar('*');
        }
        else
        {
            cout << endl << endl;;
            cout << "\t  密码过长" << endl;
        }
    }
    temp_password[len] = '\0';//字符串结束标记:\0;
    cout << endl;
    return temp_password;
}
void load_information()
{
    ifstream fin;
    fin.open(BOOK_FILE, ios::in);
    if (fin.is_open() == false)
    {
        cout << "文件打开失败!" << endl;
    }
    fin >> book_len;
 
    for (int i = 0; i < book_len; i++)
    {
        
        fin >> book[i].book_id >> book[i].book_name >> book[i].book_total_num
            >> book[i].book_student_len >> book[i].book_author >> book[i].book_type
            >> book[i].book_present;
    }
    fin.close();
 
 
    fin.open(CLASS_FILE, ios::in);
    if (fin.is_open() == false)
    {
        cout << "文件打开失败!" << endl;
    }
    fin >> class_len;
 
    for (int i = 0; i < class_len; i++)
    {
        fin >> clazz[i].class_id >> clazz[i].class_name >> clazz[i].teacher_name;
    }
    fin.close();
 
    fin.open(STUDENT_FILE, ios::in);
    if (fin.is_open() == false)
    {
        cout << "文件打开失败!" << endl;
    }
    fin >> student_len;
 
    for (int i = 0; i < student_len; i++)
    {
        fin >> student[i].id >> student[i].name >> student[i].mark>>student[i].student_grade>> student[i].class_id 
            >> student[i].student_gender >> student[i].password >> student[i].student_book_len;
    }
    fin.close();
    sort(book, book + book_len, book_cmp);
    sort(clazz, clazz + class_len, class_cmp);
    sort(student, student + student_len, student_cmp);
}
void update_information()
{
    ofstream fou;
    fou.open(BOOK_FILE, ios::out);
    if (fou.is_open() == false)
    {
        cout << "文件打开失败!" << endl;
    }
    fou << book_len << endl;
    for (int i = 0; i < book_len; i++)
    {
        fou << book[i].book_id << " " << book[i].book_name << " " << book[i].book_total_num << " " << book[i].book_student_len
            << " " << book[i].book_author << " " << book[i].book_type << " " << book[i].book_present << endl;
    }
    fou.close();
 
    fou.open(CLASS_FILE, ios::out);
    if (fou.is_open() == false)
    {
        cout << "文件打开失败!" << endl;
    }
    fou << class_len << endl;
    for (int i = 0; i < class_len; i++)
    {
        fou << clazz[i].class_id <<" "<< clazz[i].class_name <<" "<< clazz[i].teacher_name << endl;
    }
    fou.close();
 
    fou.open(STUDENT_FILE, ios::out);
    if (fou.is_open() == false)
    {
        cout << "文件打开失败!" << endl;
    }
    fou << student_len << endl;
    for (int i = 0; i < student_len; i++)
    {
        fou << student[i].id << " " << student[i].name << " " << student[i].mark<<" "<<student[i].student_grade<<" "<<student[i].class_id
            << " " << student[i].student_gender << " " << student[i].password << " " << student[i].student_book_len << endl;
    }
    fou.close();
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/qq_51133701/article/details/120674475

延伸 · 阅读

精彩推荐
  • C/C++C语言实现BMP图像处理(彩色图转灰度图)

    C语言实现BMP图像处理(彩色图转灰度图)

    这篇文章主要为大家详细介绍了C语言实现BMP图像处理,彩色图转灰度图,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考...

    傻不拉几的程序员4232022-02-15
  • C/C++C语言面试C++字符串替换空格示例

    C语言面试C++字符串替换空格示例

    这篇文章主要介绍了C语言面试中C++字符串替换空格示例,文中给出了基本上可以拿下offer的代码,有需要的朋友可以借鉴参考下,希望大家都能早日拿到心...

    小码农UU7972022-01-17
  • C/C++C语言中读取时间日期的基本方法

    C语言中读取时间日期的基本方法

    这篇文章主要介绍了C语言中读取时间日期的基本方法,分别是time()函数和gmtime()函数的使用,注意返回值的区别,需要的朋友可以参考下...

    C语言教程网4952021-03-08
  • C/C++C++实现控制台随机迷宫的示例代码

    C++实现控制台随机迷宫的示例代码

    本文主要介绍了C++实现控制台随机迷宫的示例代码,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...

    Icys10392021-12-21
  • C/C++C语言中的状态机设计深入讲解

    C语言中的状态机设计深入讲解

    这篇文章主要给大家介绍了关于C语言状态机设计的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的...

    秃头大哥10152021-10-06
  • C/C++C++实现LeetCode(86.划分链表)

    C++实现LeetCode(86.划分链表)

    这篇文章主要介绍了C++实现LeetCode(86.划分链表),本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下...

    Grandyang7312021-11-30
  • C/C++基于C++输出指针自增(++)运算的示例分析

    基于C++输出指针自增(++)运算的示例分析

    本篇文章是对C++中输出指针自增(++)运算的示例进行了详细的分析介绍,需要的朋友参考下...

    C++教程网4882020-12-10
  • C/C++一篇文章带你了解C/C++的回调函数

    一篇文章带你了解C/C++的回调函数

    这篇文章主要为大家介绍了C/C++的回调函数,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助...

    MAX在码字3982022-09-03