基于c++控制台实现的学生和教师体温上报系统

就是简易的控制台程序:

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string.h>

using namespace std;

struct Student
{
    int id=0;
    char college[20];
    char grade[20];
    float temperature=0.0;
};

int main()
{
    vector<Student> Students;
    Student stu1;
    stu1.id=2001;
    memcpy(&stu1.college,"机械",20);
    memcpy(&stu1.grade,"机械一班",20);

    Student stu2;
    stu2.id=2002;
    memcpy(&stu2.college,"机械",20);
    memcpy(&stu2.grade,"机械一班",20);

    Students.push_back(stu1);
    Students.push_back(stu2);

    //stu1.college="机械";
    //教师登录账号和密码  1001  123456
    //学生初始没有账号和密码   由老师进行创建  账号位 学号,密码位 123456
    int n=0;
    while(true)
    {
        printf("1.教师端登录\n");
        printf("2.学生端登录\n");
        printf("3.退出\n");
        scanf("%d",&n);
        if(n==1)
        {
            printf("请输入教师的账号和密码\n");
            int account=0;
            int password=0;
            scanf("%d%d",&account,&password);
            if(account==1001&&password==123456)
            {
                while(true)
                {
                    printf("1.查询所有学生体温\n");
                    printf("2.查询异常学生温度\n");
                    printf("3.修改学生体温\n");
                    printf("4.退出\n");
                    scanf("%d",&n);
                    if(n==1)
                    {
                        for(int i=0;i<Students.size();++i)
                        {
                            printf("学号:%d 学院:%s 年级:%s 体温:%f\n",Students[i].id,Students[i].college,
                                   Students[i].grade,Students[i].temperature);
                        }
                    }
                    else if(n==2)
                    {
                        for(int i=0;i<Students.size();++i)
                        {
                            if(Students[i].temperature>37.3)
                            {
                                printf("学号:%d 学院:%s 年级:%s 体温:%f\n",Students[i].id,Students[i].college,
                                       Students[i].grade,Students[i].temperature);
                            }
                        }
                    }
                    else if(n==3)
                    {
                        printf("请输入要修改体温的学生学号\n");
                        int id=0;
                        scanf("%d",&id);
                        bool isSelct=false;
                        for(int i=0;i<Students.size();++i)
                        {
                            if(id==Students[i].id)
                            {
                                isSelct=true;
                                printf("请输入需改的温度\n");
                                float temp=0.0;
                                scanf("%f",&temp);
                                Students[i].temperature=temp;
                            }
                        }
                        if(!isSelct)
                            printf("未找到学号\n");
                    }
                    else if(n==4)
                    {
                        break;
                    }
                }
            }
            else
            {
                printf("用户名和密码错误,请重新选择\n");
            }
        }
        else if(n==2)
        {
            printf("请输入学生的账号和密码\n");
            int account=0;
            int password=0;
            scanf("%d%d",&account,&password);
            bool isSelect=false;
            for(int i=0;i<Students.size();++i)
            {
                if(account==Students[i].id)
                {
                    isSelect=true;
                }
            }
            if(isSelect)
            {
                if(password==123456)
                {
                    while(true)
                    {
                        printf("1.上报体温\n");
                        printf("2.退出\n");
                        int input;
                        scanf("%d",&input);
                        if(input==1)
                        {
                            printf("请输入你的体温\n");
                            float temp=0;
                            scanf("%f",&temp);
                            for(int i=0;i<Students.size();++i)
                            {
                                if(account==Students[i].id)
                                {
                                    Students[i].temperature=temp;
                                    printf("更新成功\n");
                                }
                            }
                        }
                        else if(input==2)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    printf("用户名或密码错误,重新输入\n");
                }
            }

        }
        else if(n==3)
        {
            break;
        }


    }
    return 0;


}


在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

加油吧,小杜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值