zoukankan      html  css  js  c++  java
  • 简单成绩管理系统(没有存盘)

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stdbool.h>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    #define N 300
    struct student{
      float  no;//学号
      char name[20];
      int english;
      int meth;
      int  charater;
      float ave;
    }stu[N]={0};
    bool flag=true;
    void input();
    void show_all();
    void delete_stu( );
    void search();//输入姓名查找成绩
    void over();
    void insertion();
    int main()
    {
     while(flag)
     {
      int n;
      printf("************************************************ ");
      printf("*  menu :                                                    * ");
      printf("*  1,input student's name....                      * ");
      printf("*  2,show all students                                * ");
      printf("*  3,delete one people name                     * ");
      printf("*  4,search                                                * ");
      printf("*  5,over                                                    * ");
      printf("*  6,insertion                                             * ");
      printf("************************************************ ");

      scanf("%d",&n);
      switch(n)
      {
          case 1:input();break;
          case 2:show_all();break;
          case 3:delete_stu();break;
          case 4:search();break;
          case 5:over();break;
          case 6:insertion();break;
          default:printf("misinput! try again! ");

      }
      }

      return 0;
    }

    /*初始化结构体*/
    void input()
    {
      printf("input you want to ,if you want to over ,you can input '0' ");
      int i=1;
      while(getchar()!='0')
      {
     printf(" %d studens you have get ",i-1);
      printf("no:");
      scanf("%f",&stu[i].no);
      printf("name:");
      scanf("%s",&stu[i].name);
      printf("English:");
      scanf("%d",&stu[i].english);
      printf("math:");
      scanf("%d",&stu[i].meth);
      printf("charater:");
      scanf("%d",&stu[i].charater);getchar();
      printf("successful ");
       i++;
      }
      i--;
      while(i)
      {
        stu[i].ave=(stu[i].english+stu[i].meth+stu[i].charater)/3.0;//计算平均值
        i--;
      }
    }





    void  show_all()//显示所有学生的信息
    {
      printf("all students: ");
      int i=1;
      while(stu[i].ave!=0)
      {
          printf("no:%.f,name:%s ",stu[i].no,stu[i].name);
          printf("english:%d, math:%d, charater:%d, ave:%f ",stu[i].english,stu[i].meth,stu[i].charater,stu[i].ave);
          i++;
      }
    }
    void delete_stu( )
    {
      int n;
      printf("please input serial numbel ");
      scanf("%d",&n);
      while(stu[n].ave!=0)
      {
          stu[n]=stu[n+1];
          n++;
      }
      printf("delete successful ");
      }

    void search( )
    {
      float n;
     printf("please input no you want to find");//输入学号查找对应的序列号
     scanf("%f",&n);
     int i=1;
     while(stu[i].no!=n)
      {

         i++;
      }
     printf("sserial number:%d ",i);
     printf("no:%f,name:%s ",stu[i].no,stu[i].name);
     printf("english:%d,math:%d,charater:%d,ave:%f ",stu[i].english,stu[i].meth,stu[i].charater,stu[i].ave);

    }


    void over()
    {

        flag=false;
        printf("thank you !!!!");
    }

    void insertion()
    {
     int i=1;
     while(stu[i].ave!=0){
        i++;
     }
     printf("i=%d ",i);
      printf("no:");
      scanf("%f",&stu[i].no);
      printf("name:");
      scanf("%s",&stu[i].name);
      printf("English:");
      scanf("%d",&stu[i].english);
      printf("math:");
      scanf("%d",&stu[i].meth);
      printf("charater:");
      scanf("%d",&stu[i].charater);getchar();
      stu[i].ave=(stu[i].english+stu[i].meth+stu[i].charater)/3.0;
      printf("successful ");
    }



  • 相关阅读:
    python打印4个九九乘法表
    mysql语法归纳总结
    帆软BI报表的创建
    jmeter+influxdb+grafana可视化监控接口测试
    jmeter 自动化
    linux安装docker+jmeter分布式
    jmeter连接mysql数据库
    cmd切换盘符
    jmeter接口测试教程
    python3 进程中 获取进程号和杀死进程
  • 原文地址:https://www.cnblogs.com/yusuph/p/13202801.html
Copyright © 2011-2022 走看看