当前位置:网站首页>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语句还有各个函数来进行的操作。代码逻辑很简单很明确。
边栏推荐
- TypeError: __init__() got an unexpected keyword argument ‘autocompletion‘
- What is the material of 16MnDR, the minimum service temperature of 16MnDR, and the chemical composition of 16MnDR
- 《微机原理》——微处理器内部及外部结构
- 爬虫知识点总结
- How to use OKR as the leadership framework of marketing department
- CPU設計實戰-第四章實踐任務一簡單CPU參考設計調試
- 性能提升2-3倍!百度智能云第二代昆仑芯服务器上线
- Leetcode T39: 组合总和
- [detailed explanation of Huawei machine test] judgment string subsequence [2022 Q1 Q2 | 200 points]
- Only in China! Alicloud container service enters the Forrester leader quadrant
猜你喜欢

1.jetson与摄像头的对接

15Mo3 German standard steel plate 15Mo3 chemical composition 15Mo3 mechanical property analysis of Wuyang Steel Works

Comprehensive experiment Li

Brief introduction to AES

"Analysis of 43 cases of MATLAB neural network": Chapter 30 design of combined classifier based on random forest idea - breast cancer diagnosis

Vscode customize the color of each area

性能提升2-3倍!百度智能云第二代昆仑芯服务器上线

Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates

How can enterprises and developers take the lead in the outbreak of cloud native landing?

Do you know how data is stored? (C integer and floating point)
随机推荐
How can enterprises and developers take the lead in the outbreak of cloud native landing?
目标检测的yolov3、4、5、6总结
Guidelines and principles of did
Leetcode t34: find the first and last positions of elements in a sorted array
Count number of rows per group and add result to original data frame
电脑小技巧
Huawei machine test questions column subscription Guide
Yolov5进阶之七目标追踪最新环境搭建
View drawing process analysis
Leetcode t39: combined sum
分享2022上半年我读过的7本书
Advanced API
C语言指针的进阶(下)
挖财打新股安全吗
Gateway-88
《单片机原理及应用》—定时器、串行通信和中断系统
SPL installation and basic use (II)
There are many problems in sewage treatment, and the automatic control system of pump station is solved in this way
DID的使用指南,原理
长安链同步节点配置与启动