当前位置:网站首页>C语言学生信息管理系统
C语言学生信息管理系统
2022-07-01 08:33:00 【用编程写诗】
源码如下:
//创建5位同学,每一位同学信息都有:学号、班级、姓名、性别、C语言成绩。
//对这五位同学的信息进行管理。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <windows.h>
typedef struct LNode{
char number[20];//学号
char depth[20];//班级
char name[20];//姓名
char sex[20];//性别
double score; //成绩
}user;
user userx[100];
int usern;//全部的用户数目
//展示所有用户
void showalluser()
{
int i;
printf(" 展示所有用户 \n");
for(i=0;i<usern;i++)
{
printf("学号:%s 姓名:%s 性别:%s 班级:%s 成绩:%lf\n",userx[i].number,userx[i].name,userx[i].sex,userx[i].depth ,userx[i].score);
}
return;
}
//插入用户
void insertuser()
{
int i;
usern=5;
printf(" 录入用户信息 \n");
for(i=0;i<usern;i++)
{
printf(" 请输入学号 \n");
scanf("%s",&userx[i].number);
printf(" 请输入性别 \n");
scanf("%s",&userx[i].sex);
printf(" 请输入姓名 \n");
scanf("%s",&userx[i].name);
printf(" 请输入班级 \n");
scanf("%s",&userx[i].depth);
printf(" 请输入c语言成绩 \n");
scanf("%lf",&userx[i].score);
printf("录入成功\n");
}
}
//求平均分
void getAvg()
{
double avg=0;
int i;
for(i=0;i<usern;i++)
{
avg+=userx[i].score;
}
avg=avg/usern;
printf("平均分%lf\n",avg);
}
//统计男女人数
void tongji()
{
int a=0;
int b=0;
int i;
for(i=0;i<usern;i++)
{
if(strcmp(userx[i].sex,"男")==0)
{
a++;
}
else
{
b++;
}
}
printf("男生人数%d 女生人数%d\n",a,b);
}
//成绩最低
void getMin()
{
double min=userx[0].score;
int index=0;
int i;
for(i=0;i<usern;i++)
{
if(min>userx[i].score)
{
min=userx[i].score;
index=i;
}
}
printf("成绩最低\n");
printf("学号:%s 姓名:%s 性别:%s 班级:%s 成绩:%lf\n",userx[index].number,userx[index].name,userx[index].sex,userx[index].depth ,userx[index].score);
}
//管理员界面
void guanmian()
{
int n;
while(1)
{
printf(" 学生信息管理系统\n");
printf("################################################################################\n");
printf(" 1.录入学生信息 \n");
printf(" 2.所有信息浏览 \n");
printf(" 3.求平均分 \n");
printf(" 4.统计男女人数 \n");
printf(" 5.求成绩最低 \n");
printf(" 6.退出 \n");
printf("################################################################################\n");
scanf("%d",&n);
switch(n)
{
case 1:
insertuser();
break;
case 2:
showalluser();
break;
case 3:
getAvg();
break;
case 4:
tongji();
break;
case 5:
getMin();
break;
case 6:
printf(" 退出 \n");
system("cls");
return;
default:
printf("错误信息\n");
system("cls");
}
}
return ;
}
int main()
{
guanmian();
return 0;
}
这个系统是采用的很简单的结构体数组的方式来进行的,利用结构体数组和switch语句还有各个函数来进行的操作。代码逻辑很简单很明确。
边栏推荐
- 截图小妙招
- Li Kou 1358 -- number of substrings containing all three characters (double pointer)
- Suivi des cibles de manoeuvre - - mise en oeuvre du modèle statistique actuel (modèle CS) filtre Kalman étendu / filtre Kalman sans trace par MATLAB
- Computer tips
- What is the material of 16mo3 steel plate? What is the difference between 16mo3 and Q345R?
- Foundation: 2 The essence of image
- Field agricultural irrigation system
- Maneuvering target tracking -- current statistical model (CS model) extended Kalman filter / unscented Kalman filter matlab implementation
- [no title] free test questions for constructor municipal direction general foundation (constructor) and theoretical test for constructor municipal direction general foundation (constructor) in 2022
- 2022 mechanical fitter (primary) examination summary and mechanical fitter (primary) reexamination examination
猜你喜欢

【C】 Summary of wrong questions in winter vacation

截图小妙招

What is the material of 16mo3 steel plate? What is the difference between 16mo3 and Q345R?

The use of word in graduation thesis

Comprehensive experiment Li

你了解数据是如何存储的吗?(C整型和浮点型两类)

Advanced C language pointer (Part 2)

基于Gazebo的无人机管道检测

《微机原理》-绪论

Centos7 shell脚本一键安装jdk、mongo、kafka、ftp、postgresql、postgis、pgrouting
随机推荐
Only in China! Alicloud container service enters the Forrester leader quadrant
[deep analysis of C language] - data storage in memory
Yolov5 advanced six target tracking environment construction
2022.2.15
【面试必刷101】链表
What is the material of 15CrMoR, mechanical properties and chemical analysis of 15CrMoR
機動目標跟踪——當前統計模型(CS模型)擴展卡爾曼濾波/無迹卡爾曼濾波 matlab實現
Audio-AudioRecord create(一)
"Analysis of 43 cases of MATLAB neural network": Chapter 30 design of combined classifier based on random forest idea - breast cancer diagnosis
How to use OKR as the leadership framework of marketing department
Redis publish subscription
内存大小端
To prevent "activation" photos from being muddled through, databao "live detection + face recognition" makes face brushing safer
Intelligent water and fertilizer integrated control system
win7 pyinstaller打包exe 后报错 DLL load failed while importing _socket:参数错误
What is the material of 16MnDR, the minimum service temperature of 16MnDR, and the chemical composition of 16MnDR
Luogu p3799 demon dream stick
[Yu Yue education] Shandong Vocational College talking about railway reference materials
factory type_id::create过程解析
Intelligent water conservancy solution