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

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

服务器之家 - 编程语言 - C/C++ - C++实现考勤管理系统

C++实现考勤管理系统

2022-10-20 13:44我不叫喂喂喂喂喂喂喂喂 C/C++

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

本文实例为大家分享了C++实现考勤管理系统的具体代码,供大家参考,具体内容如下

设计一考勤管理系统,记录学生的缺课情况

1、设计学生类;
2、设计课程类;
3、设计考勤类;
4、录入学生的缺课情况;
5、修改某个学生的缺课情况;
6、查询某个学生的缺课情况;
7、统计一段时间内,旷课学生的名单和次数

仅供参考,尚有不足,请多多指正!

?
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
#include <iostream>
#include <cstring>
using namespace std;
 
class Student
{
    public:
        void setname(char *setname)
        {    
            strcpy(name,setname);
        }
        
        void setcarname(char *setcarname)
        {
            strcpy(carname,setcarname);
        }
        
        void setseating_capacity(char *setseating_capacity)
        {
            strcpy(seating_capacity,setseating_capacity);
        }
        
        void setidentifynumber(char *setidentifynumber)
        {
            strcpy(identifynumber,setidentifynumber);
        
        
        char *getname()
        {
            char *setname=name;
            return setname;
        }
        
        char *getcarname()
        {
            char *setcarname=carname;
            return setcarname;
        }
        
        char *getsetseating_capacity()
        {
            char *setseating_capacity=seating_capacity;
            return setseating_capacity;
        }
        
        char *getidentifynumber()
        {
            char *setidentifynumber=identifynumber;
            return setidentifynumber;
        }
        
        
    private:
        char name[30];
        char carname[30];
        char seating_capacity[30];
        char identifynumber[30];
};
 
class Course:public Student
{
    public:
        void setcoursename(char *setcoursename)
        {
            strcpy(coursename,setcoursename);
        }
        
        void setcoursetime(char *setcoursetime)
        {
            strcpy(coursetime,setcoursetime);
        
         
        void setcourseplace(char *setcourseplace)
        {
            strcpy(courseplace,setcourseplace);
        }
        
        char *getcoursename()
        {
            char *setcoursename;
            setcoursename=coursename;
            return setcoursename;
        }
        
        char *getcoursetime()
        {
            char *setcoursetime;
            setcoursetime=coursetime;
            return setcoursetime;
        }
        
        char *getcourseplace()
        {
            char *setcourseplace;
            setcourseplace=courseplace;
            return setcourseplace;
        }
        
    private:
        char coursename[30];
        char coursetime[30];
        char courseplace[30];
}; 
 
class Attendence:public Course
{
    public:
        void setattendence(int setattendence)
        {
            int i=0;
            attendence[i]=setattendence;
            i++;
        }
        
        int *getattendence()
        {
            int *setattendence;
            setattendence=attendence;
            return setattendence;
        }
    private:
        int attendence[30];
};
 
int input(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[]);
int modify(Student i[],Course cn[],Course ct[],Course cp[],Attendence attendence[],int totalnumber);
int search(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber);
int statistic(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber);
void bubble(int arr[],int len);
 
Student n[20];
Student i[20];
Course cn[20];
Course ct[20];
Course cp[20];
Attendence a[20];
 
int totalnumber=0;
char name[30];
char identifynumber[30];
char coursename[30];
char coursetime[30];
char courseplace[30];
int attendence;
int array[30];
 
int att[30];
 
int main() 
{
    while(1)
    {
        cout<<"---------吉林大学珠海学院---------\n"
            <<"         学生考勤管理系统\n\n"
            <<"      1.录入学生缺课信息\n"
            <<"      2.修改学生缺课记录\n"
            <<"      3.查询学生缺课情况\n"
            <<"      4.统计一段时间内学生旷课情况\n"
            <<"      5.退出系统\n\n"
            <<"------------------------------"<<endl;
                
        int num;
        for(;;)
        {
            cout<<"请选择需要执行的功能序号(1-5):";
            cin>>num;
            if(num>=1&&num<=5)
                break;
            else
                continue;
        }
        
        cout<<endl;
    
        switch(num){
            case 1:{
                input(n,i,cn,ct,cp,a);
                break;
            }
            
            case 2:{
                modify(i,cn,ct,cp,a,totalnumber);
                break;
            }
            
            case 3:{
                search(n,i,cn,ct,cp,a,totalnumber);
                break ;
            }
            
            
            case 4:{
                statistic(n,i,cn,ct,cp,a,totalnumber);
                break;
            }
            
            case 5:exit(0); 
        }
    }    
}
 
int input(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[])
{
    cout<<"----------请开始输入----------\n";
        cout<<"请输入将录入系统的人数:"
        cin>>totalnumber;
        cout<<endl;
    
    for(int counter=0;counter<totalnumber;counter++)
    {
        cout<<"学生姓名:";
        cin>>name; 
        n[counter].setname(name);
        cout<<"学生学号:";
        cin>>identifynumber;
        i[counter].setidentifynumber(identifynumber);
        cout<<"课程名称:";
        cin>>coursename;
        cn[counter].setcoursename(coursename);
        cout<<"课程时间(星期几,第几节课):";
        cin>>coursetime;
        ct[counter].setcoursetime(coursetime);
        cout<<"课程地点:";
        cin>>courseplace;
        cp[counter].setcourseplace(courseplace);
        cout<<"缺课次数:";
        cin>>attendence;
        a[counter].setattendence(attendence);
        array[counter]=attendence;
        cout<<'\n';
    }
    
    return 1;
}
 
 
int modify(Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber)
{
    int inputnumber;
    do{
        char id[8];
        cout<<"请输入学生学号:";
        cin>>id;
        cout<<endl;
    
        if(1)
        {
            for(int counter=0;counter<totalnumber;counter++)
            {
                if(strcmp(id,i[counter].getidentifynumber())==0)
                {
                    int num;
                    cout<<"请选择需要修改信息的种类:"
                        <<"\n1.课程名称\n"
                        <<"2.课程时间\n"
                        <<"3.课程地点\n"
                        <<"4.缺课次数\n";
                        
                    for(;;)
                    {
                        cout<<"请输入需要修改信息的代号(1-4):";
                        cin>>num;
                        if(num>=1&&num<=4)
                            break;
                        else
                            continue;
                    
                    
                    cout<<endl;
                
                    switch(num){
                        case 1:{
                            cout<<"请输入修改后的课程名称:"
                            cin>>coursename;
                            cn[counter].setcoursename(coursename);
                            cout<<'\n';
                            break;
                        }
                        
                        case 2:{
                            cout<<"请输入修改后的课程时间(星期几,第几节课):";
                            cin>>coursetime;
                            ct[counter].setcoursetime(coursetime);
                            cout<<'\n';
                            break;
                        }
                        
                        case 3:{
                            cout<<"请输入修改后的课程地点:";
                            cin>>courseplace;
                            cp[counter].setcourseplace(courseplace);
                            cout<<'\n';
                            break;
                        }
                        
                        case 4:{
                            cout<<"请输入修改后的缺课次数:";
                            cin>>attendence;
                            a[counter].setattendence(attendence);
                            array[counter]=attendence;
                            cout<<'\n';
                            break;
                        }
                        
                    }
                }
            
        }
                  
        else
        {
            cout<<"无该学生缺课信息!\n"
                <<"请再次确认输入学号无误\n\n";
        }
            
        for(;;)
        {
            cout<<"重新查询请输入1|返回目录请输入0\n"
            cin>>inputnumber;
            if(inputnumber==1||inputnumber==0)
                break;
            else
                continue;
        }
        
        
    }while(inputnumber==1);
    
    return 1;
}
 
int search(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber)
{
    int inputnumber;
    do{
        char ids[8];
        char *identify=ids;
        cout<<"请输入学生学号:";
        cin>>ids;
        cout<<endl;
        strcpy(ids,identify);
    
        if(1)
        {
            for(int counter=0;counter<totalnumber;counter++)
            {
                if(strcmp(ids,i[counter].getidentifynumber())==0)
                {
                    cout<<"学生姓名:"<<n[counter].getname()
                        <<"\n学生学号:"<<i[counter].getidentifynumber()
                        <<"\n缺课课程名称:"<<cn[counter].getcoursename()
                        <<"\n缺课课程日期:"<<ct[counter].getcoursetime()
                        <<"\n缺课时间:"<<cp[counter].getcourseplace()
                        <<"\n缺课次数:"<<*a[counter].getattendence()<<"\n";
                }
            }
        }
                
        else
            cout<<"无该同学数据"
                break;
        
        cout<<'\n'<<endl;
        for(;;)
        {
            cout<<"重新查询请输入1|返回目录请输入0\n\n";
            cin>>inputnumber;
            if(inputnumber==0||inputnumber==1)
                break;
            else
                continue;
        }
        
    }while(inputnumber==1);
    
    return 1;
}
 
int statistic(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber)
{
    int inputnumber;
    for(int index=0;index<30;index++)
        att[index]=index;
    
    if(totalnumber==0)
    cout<<"数据库无信息\n\n";
    
    else if(totalnumber==1)
    cout<<"学生姓名:"<<n[0].getname()
        <<"\n学生学号:"<<i[0].getidentifynumber()
        <<"\n缺课课程名称:"<<cn[0].getcoursename()
        <<"\n缺课课程日期:"<<ct[0].getcoursetime()
        <<"\n缺课时间:"<<cp[0].getcourseplace()
        <<"\n缺课次数:"<<*a[0].getattendence()<<"\n\n";
    
    else if(1)
    {
        for(int counter=0;counter<totalnumber;counter++)
        {
            if(a[counter].getattendence()<a[counter].getattendence()+1)
            {
                bubble(array,totalnumber);
            }
            
            else if(a[counter].getattendence()==a[counter+1].getattendence())
            {
                if(strcmp(i[counter].getidentifynumber(),i[counter+1].getidentifynumber())>0)
                {
                    int temp;
                    int a=counter;
                    int b=counter+1;
                    
                    temp=a;
                    a=b;
                    b=temp;
                }
            }
            
        }
 
        for(int index=0;index<totalnumber;index++)
        {
            cout<<"学生姓名:"<<n[att[index]].getname()
                <<"\n学生学号:"<<i[att[index]].getidentifynumber()
                <<"\n缺课课程名称:"<<cn[att[index]].getcoursename()
                <<"\n缺课课程日期:"<<ct[att[index]].getcoursetime()
                <<"\n缺课时间:"<<cp[att[index]].getcourseplace()
                <<"\n缺课次数:"<<*a[att[index]].getattendence()<<"\n\n";
        }
        
    }
    
    cout<<"返回目录请输入0\n";
    cin>>inputnumber;
    if(inputnumber==0)
        return 1;
}
 
void bubble(int arr[],int len)
{
    int i,j,temp;
    int t;
    for(i=0;i<len-1;i++)
    {
        for(j=0;j<len-1-i;j++)
        {
            if(arr[j]<arr[j+1])
            {
                temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;    
            
                t=att[j];
                att[j]=att[j+1];
                att[j+1]=t; 
            }
        }
    }
}

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

原文链接:https://blog.csdn.net/weixin_53360289/article/details/115534133

延伸 · 阅读

精彩推荐
  • C/C++C++实现简单扫雷游戏

    C++实现简单扫雷游戏

    这篇文章主要为大家详细介绍了C++实现简单扫雷游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...

    梦醒...4362021-08-25
  • C/C++C++命名空间5种常见用法实例解析

    C++命名空间5种常见用法实例解析

    这篇文章主要介绍了C++命名空间5种常见用法实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以...

    Gesündeste7942021-09-13
  • C/C++汇编语言rep movsd 的使用详解

    汇编语言rep movsd 的使用详解

    rep movsd 每次ecx!=0便执行movsd ,然后ecx=ecx-1 movsd移动ds:[si] 到es:[di],在32位汇编下可以用esi代替si,edi代替di...

    C语言教程网4762020-12-30
  • C/C++C语言计算Robots机器人行走路线

    C语言计算Robots机器人行走路线

    这篇文章介绍了C语言计算Robots机器人行走路线,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...

    天笙月11752022-07-14
  • C/C++C语言实现密码本

    C语言实现密码本

    这篇文章主要为大家详细介绍了C语言实现密码本,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...

    初识逆向9742021-08-19
  • C/C++C++设计模式之抽象工厂模式

    C++设计模式之抽象工厂模式

    这篇文章主要介绍了C++设计模式之抽象工厂模式,本文要讲的抽象工厂模式,就是工厂方法模式的扩展和延伸,需要的朋友可以参考下...

    果冻想7072021-02-03
  • C/C++C语言基础隐式类型转换与强制类型转换示例解析

    C语言基础隐式类型转换与强制类型转换示例解析

    最接地气的有关类型转换的介绍,此处对于类型转换的相关知识点做一些简要的介绍,作者实属初学,难免文章中有内容理解不到位或者有不当之处,还请...

    RookieStriver3402022-02-27
  • C/C++C++实现LeetCode(15.三数之和)

    C++实现LeetCode(15.三数之和)

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

    Grandyang6622021-11-23