当前位置:网站首页>Student attendance system for C language course (big homework)
Student attendance system for C language course (big homework)
2022-07-01 06:26:00 【Ordinary senior】

One 、 Design function ( The article is for reference only )
(1) Determine the interface , Enables the user to select an action item
(2) Input function : Use structure , Ask the user to enter the corresponding information , And save it in the file
(3) Query function : Search by name or student number , Use the loop to find the corresponding structure array elements , Then output the required The information you want
(4) Attendance scoring : The system outputs student scores according to the number of absenteeism of students in the attendance file in the percentage system , Five points will be deducted from truancy ;
Two 、 Function display




3、 ... and 、 Mind mapping



Four 、 Program source code
#include<stdio.h>
#include<string.h> /* The header file .*/
int SIZE; /* Macro definition .*/
int CLASS;
struct student /* Define a structure array , Contains student information .*/
{
char name[9];
char sex[4];
int number;
int count;
int score;
}stu[300];
int main() /* The main function , Selection interface .*/
{
void start();
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\t\t\t######################################\n");
printf("\t\t\t# Student attendance system #\n");
printf("\t\t\t# huan To meet you #\n");
printf("\t\t\t######################################\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\t\t######################################\n");
printf("\t\t\t Please enter the class size :\n");
printf("\t\t######################################\n");
scanf("%d",&SIZE);
printf("\n");
printf("\t\t######################################\n");
printf("\t\t\t Please enter the number of courses :\n");
printf("\t\t######################################\n");
scanf("%d",&CLASS);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
start();
}
void start() /* Auxiliary function of main function --start function .*/
{
char x;
void found();
void search();
void add();
void mark();
printf("######################################\n");
printf("# Please select the required function , Enter the corresponding number : #\n");
printf("# 1. Create a student list #\n");
printf("# 2. Search for student information #\n");
printf("# 3. Simulate the attendance process #\n");
printf("# 4. Calculate attendance score #\n");
printf("# 5. sign out #\n");
printf("# #\n");
printf("######################################\n");
scanf("%S",&x);
switch(x) /* utilize switch Function to realize the selection function of sub function .*/
{
case'1':found();break;
case'2':search();break;
case'3':add1();break;
case'4':mark();break;
case'5':break;
default :printf("**** Incorrect input , Please re-enter :\n");start();
}
}
void found() /* The first sub function --found function , Used to create a student list .*/
{
int a;
printf("####################\n");
printf(" Start building tables .\n");
printf("####################\n");
FILE *fp;
for(a=0;a<SIZE;a++) /* Application for loop , Input student information one by one .*/
{
printf(" Please enter the first %d A student's personal information :\n",a+1);
printf(" full name :");
scanf("%s",stu[a].name);
printf(" Gender :");
scanf("%s",stu[a].sex);
printf(" Student number :");
scanf("%d",&stu[a].number);
stu[a].count=0;
stu[a].score=0;
}
fp=fopen("stud","w"); /* Create a new file , Application for Function to write student information to a file .*/
for(a=0;a<SIZE;a++)
{
if(fwrite(&stu[a],sizeof(struct student),1,fp)!=1)
printf(" File input error .\n");
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" The table is as follows :\n");
fp=fopen("stud","r"); /* Read the new file , And the output .*/
printf(" full name \t Gender \t Student number \t Number of missed classes \t Attendance score \n");
printf("----------------------------------------------\n");
for(a=0;a<SIZE;a++)
{
fread(&stu[a],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d \t%d\n",stu[a].name,stu[a].sex,stu[a].number,stu[a].count,stu[a].score);
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("#######################################\n");
printf("# Record it #\n");
printf("# look forward to seeing you next time . #\n");
printf("#######################################\n");
start(); /* Return the auxiliary function of the main function , Main menu .*/
}
void search() /* The second sub function --search function , Used to query student information .*/
{
char b;
void search1();
void search2();
printf("****************************************\n");
printf(" Please select :\n");
printf(" 1. Search by name .\n");
printf(" 2. Search by student ID .\n");
printf("****************************************\n");
scanf("%s",&b);
switch(b) /* Application switch function , Form a selection structure , You can select query types .*/
{
case'1':search1();break; /* In the first 1 Functions of query types .*/
case'2':search2();break; /* In the first 2 Functions of query types .*/
default :printf("**** Incorrect input , Please re-enter :");search();
}
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("#######################################\n");
printf("# To find the end #\n");
printf("# look forward to seeing you next time . #\n");
printf("#######################################\n");
start(); /* Return the auxiliary function of the main function , Main menu .*/
}
void search1() /* The first 1 Functions of query types .*/
{
int c;
char student_name[9];
FILE *fp; /* Open the created file and output it to the screen .*/
fp=fopen("stud","r");
printf(" full name \t Gender \t Student number \t Number of missed classes \t Attendance score \n");
printf("----------------------------------------------\n");
for(c=0;c<SIZE;c++)
{
fread(&stu[c],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d \t%d\n",stu[c].name,stu[c].sex,stu[c].number,stu[c].count,stu[c].score);
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" Please enter the name of the student to be queried :");
scanf("%s",student_name);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
for(c=0;c<SIZE;c++) /* Application for Circulation and strcmp The function compares the entered names one by one with the names of students in the list , Output the information of the student after finding the same .*/
{
if(strcmp(student_name,stu[c].name)==0)
{
printf(" Found *******************************************\n");
printf(" full name :%s Gender :%s Student number :%d Number of missed classes :%d\n",stu[c].name,stu[c].sex,stu[c].number,stu[c].count);
}
}
}
void search2() /* The first 2 Functions of query types .*/
{
int c;
int d;
FILE *fp;
fp=fopen("stud","r");
printf(" full name \t Gender \t Student number \t Number of missed classes \t Attendance score \n");
printf("----------------------------------------------\n");
for(c=0;c<SIZE;c++)
{
fread(&stu[c],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d \t%d\n",stu[c].name,stu[c].sex,stu[c].number,stu[c].count,stu[c].score);
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" Please enter the student ID you want to query :");
scanf("%d",&d);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
for(c=0;c<SIZE;c++) /* Same as 1 Functions of query types , use for Cycle to compare the entered student ID with the student ID in the list one by one , Output the information of the student after finding the same .*/
{
if(d==stu[c].number)
{
printf(" Found *********************************************\n");
printf(" full name :%s Gender :%s Student number :%d Number of missed classes :%d\n",stu[c].name,stu[c].sex,stu[c].number,stu[c].count);
}
}
}
int add1() /* The third sub function --add function , Used to simulate attendance process .*/
{
int e,f,y;
struct name /* Build another one called name Array of structs .*/
{
char nam[9];
}na[300];
FILE *fp;
fp=fopen("stud","r"); /* Open the created file and output it to the screen .*/
for(e=0;e<SIZE;e++)
{
fread(&stu[e],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d \t%d\n",stu[e].name,stu[e].sex,stu[e].number,stu[e].count,stu[e].score);
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("***************************\n");
printf(" Simulated attendance starts .\n");
printf("***************************\n");
for(e=0;e<CLASS;e++) /* Application for Nesting of loops , towards name Enter the name in the structure , Then compare with the student names in the list one by one .*/
{
printf(" Please enter the first %d The names of the students who have not arrived in the class shall be marked with 'over' end :",e+1);
for(y=0;y<=SIZE;y++)
{
scanf("%s",na[y].nam);
for(f=0;f<SIZE;f++)
{
if(strcmp(na[y].nam,stu[f].name)==0) /* If the name entered is the same as that of a student , In its count Add... To the information of 1.*/
stu[f].count++;
}
if(strcmp(na[y].nam,"over")==0) /* The loop ends , encounter "over", Exit loop .*/
break;
}
}
fp=fopen("stud","w"); /* Write the new list data to the original file .*/
for(e=0;e<SIZE;e++)
{
if(fwrite(&stu[e],sizeof(struct student),1,fp)!=1)
printf(" File input error .\n");
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" Simulated attendance completed , give the result as follows :\n");
fp=fopen("stud","r"); /* Open the updated file and output it to the screen .*/
printf(" full name \t Gender \t Student number \t Number of missed classes \n");
printf("-------------------------\n");
for(f=0;f<SIZE;f++)
{
fread(&stu[f],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d\n",stu[f].name,stu[f].sex,stu[f].number,stu[f].count);
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("#######################################\n");
printf("# Attendance check completed #\n");
printf("# look forward to seeing you next time . #\n");
printf("#######################################\n");
start(); /* Return the auxiliary function of the main function .*/
}
void mark() /* The fourth sub function --mark function , Used to calculate attendance score .*/
{
int g;
FILE *fp; /* Open the updated file and output it to the screen .*/
fp=fopen("stud","r+");
printf(" full name \t Gender \t Student number \t Number of missed classes \n");
printf("----------------------------------------------\n");
for(g=0;g<SIZE;g++)
{
fread(&stu[g],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d\n",stu[g].name,stu[g].sex,stu[g].number,stu[g].count);
}
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("********************************\n");
printf(" Scoring start .\n");
printf("********************************\n");
for(g=0;g<SIZE;g++) /* use for Cycle the scoring process .*/
{
stu[g].score=(100-stu[g].count*5); /* Five points will be deducted for missing a class .*/
if(stu[g].score<0)
stu[g].score=0;
}
fclose(fp);
fp=fopen("stud","w"); /* Write the updated student list information into the original file .*/
for(g=0;g<SIZE;g++)
{
if(fwrite(&stu[g],sizeof(struct student),1,fp)!=1)
printf(" File input error .\n");
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf(" give the result as follows :\n");
fp=fopen("stud","r"); /* Open the updated file and output it to the screen .*/
printf(" full name \t Gender \t Student number \t Number of missed classes \t Attendance score \n");
printf("----------------------------------------------\n");
for(g=0;g<SIZE;g++)
{
fread(&stu[g],sizeof(struct student),1,fp);
printf("%s \t%s \t%d \t%d \t%d\n",stu[g].name,stu[g].sex,stu[g].number,stu[g].count,stu[g].score);
}
fclose(fp);
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("#######################################\n");
printf("# After scoring #\n");
printf("# look forward to seeing you next time . #\n");
printf("#######################################\n");
start(); /* Return the auxiliary function of the main function , Main menu .*/
}

You can pay attention to it, and it will be updated continuously in the future 0.0( Thank you first )
边栏推荐
- ABP 学习解决方案中的项目以及依赖关系
- 【ManageEngine卓豪】局域网监控的作用
- C语言课设职工信息管理系统(大作业)
- Self confidence is indispensable for technology
- [ManageEngine] terminal management system helps Huasheng securities' digital transformation
- libpng12.so. 0: cannot open shared object file: no such file or directory
- [ManageEngine Zhuohao] use unified terminal management to help "Eurex group" digital transformation
- On siem
- 地宮取寶(記憶化深搜)
- ManageEngine卓豪助您符合ISO 20000标准(四)
猜你喜欢
随机推荐
【ManageEngine】终端管理系统,助力华盛证券数字化转型
DHT11 temperature and humidity sensor
XAF Bo of dev XPO comparison
手把手教你实现一个深度学习框架...
Excel visualization
Kubedm builds kubenetes cluster (Personal Learning version)
做技术,自信不可或缺
阶乘约数(唯一分解定理)
三分钟带你快速了解网站开发的整个流程
sql中TCL语句(事务控制语句)
Picture server project test
Save data in browser to local file
Pol8901 LVDS to Mipi DSI supports rotating image processing chip
idea 好用插件汇总!!!
ManageEngine卓豪助您符合ISO 20000标准(四)
webapck打包原理--启动过程分析
golang panic recover自定义异常处理
Comment imprimer le tableau original
SystemVerilog learning-07-class inheritance and package use
讓田頭村變甜頭村的特色農產品是仙景芋還是白菜

![[file system] how to run squashfs on UBI](/img/d7/a4769420c510c47f3c2a615b514a8e.png)







