题目要求:

学生信息管理系统
struct studentInfo
{
  int id;
  char name[128];
  int age;
  char sex;
  int c_score;
  int cpp_score;
  int oc_scpre;
};

struct StudentInfo Arr[100]={};
int count=0;

show
1. 插入用户信息
scnaf("%s%d", Arr[count].age);
count++;

2. 显示用户信息
  (1)输入id,按id显示信息
  (2)输入name,按name显示信息

3. 显示所有用户信息

4. 删除用户信息
  (1)输入id,按id删除信息
  (2)输入name,按name删除信息

5. 统计
  c-score 平均值
  cpp-score-平均值
  oc-score平均值
  平均值成绩最高分

input: 1-6
switch()
{

}

我的代码:

#include <stdio.h>
#include <string.h>
typedef struct studentInfo{
int id;
char name[128];
int age;
char sex;
int c_score;
int cpp_score;
int oc_score;
}Student;
Student student[1000];
int pos; void print_info(int p){
printf("%d\t%s\t%d\t%c\t%d\t%d\t%d\n",
student[p].id, student[p].name, student[p].age, student[p].sex,
student[p].c_score, student[p].cpp_score, student[p].oc_score);
} void input();
void show(){
printf("\n\n\n");
printf("-----------------管理信息系统---------------------------\n");
printf("| |\n");
printf("| |\n");
printf("| 1.插入用户信息 |\n");
printf("| 2.显示用户信息 |\n");
printf("| 3.显示所有用户信息 |\n");
printf("| 4.删除用户信息 |\n");
printf("| 5.统计信息 |\n");
printf("| 6.退出系统 |\n");
printf("| |\n");
printf("--------------------------------------------------------|\n");
printf("请输入数字:(1-6)\n");
input();
} void insert(){
char name[128];
int i = 0;
++pos;
printf("Please input user id :\n");
scanf("%d", &student[pos].id);
printf("Please input user name :\n");
scanf("%s", name);
strcpy(student[pos].name, name);
printf("Please input user age :\n");
scanf("%d", &student[pos].age);
printf("Please input user sex :\n");
scanf(" %c", &student[pos].sex);
printf("Please input user C语言分数 :\n");
scanf("%d", &student[pos].c_score);
printf("Please input user C++分数 :\n");
scanf("%d", &student[pos].cpp_score);
printf("Please input user objective-c 分数 :\n");
scanf("%d", &student[pos].oc_score);
printf("插入成功!\n");
show();
} void showuser(){
printf("1>输入id, 按ID显示信息\n");
printf("2>输入name, 按name显示信息\n");
printf("请输入序号:(1-2)\n");
int i, id, num;
char name[128];
scanf("%d", &num);
if(num == 1){
printf("请输出ID:\n");
scanf("%d", &id);
for(i=1;i<=pos;++i)
if(id == student[i].id){
printf("ID\t名字\t年龄\t性别\tC\tC++\tOC\n");
print_info(i);
}
}
if(num == 2){
printf("请输入用户名字:\n");
scanf("%s", name);
for(i=1;i<=pos;++i)
if(!strcmp(name, student[i].name)){
printf("ID\t名字\t年龄\t性别\tC\tC++\tOC\n");
print_info(i);
}
}
printf("按任意键返回菜单\n");
getchar();
getchar();
show();
} void showalluser(){
int i = 0;
printf("ID\t名字\t年龄\t性别\tC\tC++\tOC\n");
for(i=1;i<=pos;++i){
if(student[i].id == 0) continue;
print_info(i);
}
show();
} void delete(){
printf("1>输入id, 按ID删除信息\n");
printf("2>输入name, 按name删除信息\n");
printf("请输入序号:(1-2)\n");
int i, id, num;
char name[128];
scanf("%d", &num);
if(num == 1){
printf("请输入ID\n");
scanf("%d", &id);
for(i=1;i<=pos;++i)
if(id == student[i].id){
student[i].id = 0;
printf("删除成功!\n");
}
}
if(num == 2){
printf("请输入用户名字:\n");
scanf("%s", name);
for(i=1;i<=pos;++i)
if(!strcmp(name, student[i].name)){
student[i].id = 0;
printf("删除成功!\n");
}
}
show();
} void sum(){
printf("1>输入C语言分数的平均值信息\n");
printf("2>输入C++语言分数的平均值信息\n");
printf("3>输入objective-C语言分数的平均值信息\n");
printf("请输入序号:(1-3)\n");
int num, i, sum, cnt;
scanf("%d", &num);
if(num == 1){
cnt = 0;
sum = 0;
for(i=1;i<=pos;++i){
if(student[i].id == 0) continue;
cnt++;
sum+=student[i].c_score;
}
printf("C语言评分分数 :%g\n", sum/(cnt*1.0));
}
if(num == 2){
cnt = 0;
sum = 0;
for(i=1;i<=pos;++i){
if(student[i].id == 0) continue;
cnt++;
sum+=student[i].cpp_score;
}
printf("C++语言评分分数 :%g\n", sum/(cnt*1.0));
}
if(num == 3){
cnt = 0;
sum = 0;
for(i=1;i<=pos;++i){
if(student[i].id == 0) continue;
cnt++;
sum+=student[i].oc_score;
}
printf("objective-C语言评分分数 :%g\n", sum/(cnt*1.0));
}
if(num == 4){
cnt = 0;
sum = 0;
for(i=1;i<=pos;++i){
if(student[i].id == 0) continue;
cnt++;
sum+=student[i].oc_score;
}
printf("objective-C语言评分分数 :%f\n", sum/(cnt*1.0));
}
show();
} void _quit(){} void input(){
int num;
scanf("%d", &num);
switch(num){
case 1: insert();
break;
case 2: showuser();
break;
case 3: showalluser();
break;
case 4: delete();
break;
case 5: sum();
break;
case 6: _quit();
break;
}
} int main(){
pos = 0;
show();
return 0;
}

  

运行结果 截图:

C语言练习-学生信息管理系统的更多相关文章

  1. C语言版本学生信息管理系统

    仍然有一些小bug,后续会发布OC完善版的图书馆管理系统,欢迎批评指正. #include <stdio.h> void menu_choose(); typedef struct { i ...

  2. 【转载】C语言综合实验1—学生信息管理系统

    http://www.cnblogs.com/Anker/archive/2013/05/06/3063436.html 实验题目:学生信息管理系统 实验要求:用户可以选择1-7可以分别进行学生信息的 ...

  3. C语言小练习之学生信息管理系统

    C语言小练习之学生信息管理系统 main.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 2 ...

  4. 大一C语言结课设计之《学生信息管理系统》

    第一次写这么长的程序,代码仅供參考,有问题请留言. /* ** 学生信息管理系统 ** IDE:Dev-Cpp 4.9.9.2 ** 2014-6-15 */ #include <stdio.h ...

  5. 学生信息管理系统(c语言)

    ①注意: 程序中使用了sleep()函数.system()函数 关于 sleep() 函数 sleep() 函数的头文件和用法会因环境的不同而有所不同. 具体见-sleep()函数功能及用法 关于sy ...

  6. 学生信息管理系统(C语言)

    #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct student ...

  7. 基于数组或链表的学生信息管理系统(小学期C语言程序实训)

    1.基于数组的学生信息管理系统 实验内容: 编写并调试程序,实现学校各专业班级学生信息的管理.定义学生信息的结构体类型,包括:学号.姓名.专业.班级.3门成绩. 实验要求: (1) main函数:以菜 ...

  8. 【Python3.6+Django2.0+Xadmin2.0系列教程之二】学生信息管理系统(入门篇)

    上一篇我们已经创建好了一个Xadmin的基础项目,现在我们将在此基础上构建一个同样很基础的学生信息管理系统. 一.创建模型 模型是表示我们的数据库表或集合类,并且其中所述类的每个属性是表或集合的字段, ...

  9. C语言实现---学生成绩管理系统

    C语言实现了学生成绩管理系统,可以进行学生成绩的增加,删除,更新,查询,计算和展示. 完整代码如下: #include<stdio.h> #include<stdlib.h> ...

随机推荐

  1. L轻松学习inux教程5 知识与学习bash

    本系列文章由@超人爱因斯坦出品,转载请注明出处.          文章链接:          http://hpw123.net/a/Linux/Linuxjichu/2014/1031/101. ...

  2. Entity Framework执行Sql语句返回DataTable

    Entity Framework中对外开放了数据库连接字符串,使用的时候可以直接得到这个连接字符串,然后进行相关的操作.如果在使用的过程中,发现Entity Framework中有一些满足不了的需求的 ...

  3. Android apk file

    apk file 事实上zip文件. 您可以使用unzip命令提取. unzip example1.apk -d ./example_dir tree . ├── AndroidManifest.xm ...

  4. 使用ArcGIS API for Silverlight实现地形坡度在线分析

    原文:使用ArcGIS API for Silverlight实现地形坡度在线分析 苦逼的研究生课程终于在今天结束了,也许从今以后再也不会坐在大学的课堂上正式的听老师讲课了,接下来的时间就得开始找工作 ...

  5. 表达式树 Expression

    转载泛型方法动态生成表达式树 Expression public string GetGridJSON(TraderInfo model) { IQueryable<TraderInfo> ...

  6. HDU 3639 Hawk-and-Chicken(Tarjan缩点+反向DFS)

    Problem Description Kids in kindergarten enjoy playing a game called Hawk-and-Chicken. But there alw ...

  7. Opencv on Ubuntu (from Ubuntu)

     OpenCV Introduction Contents Introduction Installation Step 1 Step 2 Running OpenCV Python in C I ...

  8. Self referencing loop detected with type

    json.net namespace EFDAL{    using System;    using System.Collections.Generic;    using Newtonsoft. ...

  9. Hibernate实体映射配置(XML)简单三步完美配置

    我们在使用Hibernate框架的时候,非常纠结的地方就是实体和表之间的映射,今天借助汤老师的思路写了小教程,以后配置不用纠结了! 第一步:写注释 格式为:?属性,表达的是本对象与?的?关系. 例:“ ...

  10. SQL data reader reading data performance test

    /*Author: Jiangong SUN*/ As I've manipulated a lot of data using SQL data reader in recent project. ...