求"机房管理系统"C语言程序设计

Python017

求"机房管理系统"C语言程序设计,第1张

具体要求如下:

1、 采取模块化方式进行程序设计,要求程序的功能设计、数据结构设计及整体结构设计合理。学生也可根据自己对题目的理解增加新的功能模块(视情况可另外加分)。

2、 系统以菜单界面方式(至少采用文本菜单界面,如能采用图形菜单界面更好)工作,运行界面友好,演示程序以用户和计算机的对话方式进行。

3、 程序算法说明清晰,理论分析与计算正确,运行情况良好,实验测试数据无误,容错性强(能对错误输入进行判断控制)。

4、 编程风格良好(包括缩进、空行、适当注释、变量名和函数名见名知意,程序容易阅读等);

5、 写出规范的课程设计报告,具体要求见相关说明文档。

某学校有实验机房n个,每个机房管理信息包括:(房间号、机房类型、可容纳学生人数、实验员、是否在使用)。

例如:

房间号 机房类型 可容纳学生人数 实验员 是否在使用

01网络实验 40 张是

02软件实验 90 林否

03系统结构实验 45 丁否

04软件实验 120 马否

功能要求:

(1)录入实验室信息,可增加、删除实验机房信息。如果机房正在使用,不能删除。

(2)浏览所有机房信息,可显示出所有实验室情况

(3)如果有班级申请某类型实验室,若有该类型的空机房,且容量大于班级学生数,则分配该机房,更新管理信息。

(4)可以根据房间号或机房类型查询所有机房信息

C语言是Combined Language(组合语言)的中英混合简称。是一种计算机程序设计语言。它既具有高级语言的特点,又具有汇编语言的特点。它可以作为工作系统设计语言,编写系统应用程序,也可以作为应用程序设计语言,编写不依赖计算机硬件的应用程序。因此,它的应用范围广泛,不仅仅是在软件开发上,而且各类科研都需要用到C语言,具体应用比如单片机以及嵌入式系统开发。

#include<time.h>

#include<stdio.h>

#include<string.h>

#include<Windows.h>

#define N 20 

#define M 100 

struct student {

    char id[N]

    char theclass[N]

    char name[N]

    char ontime[N]

}student[M]

int n

void addition(){

    int i

    printf("\n请输入录入学生信息的总数:")

    scanf("%d",&n)

    for(i=1i<=ni++){

        printf("\n\t请输入第%d个学生学号(20s):",i)

        scanf("%s",student[i-1].id)

        printf("\n\t请输入第%d个学生班级(20s):",i)

        scanf("%s",student[i-1].theclass)

        printf("\n\t请输入第%d个学生姓名(20s):",i)

        scanf("%s",student[i-1].name)

        printf("\n\t请输入第%d个学生上机时间(20s)(例:02):",i)

        scanf("%s",student[i-1].ontime)

        printf("\n\t提示:您已成功录入第%d条信息\n",i)

    }

}

//计算功能:计算每个下机学生的上机费用,每小时1元。上机费用=上机时间* 1.0/h ,不足一小时按一小时计算) 

void calculate(){

    int hours

    char times[30]

    time_t rawtime  

    struct tm * timeinfo 

    time ( &rawtime ) 

    timeinfo = localtime(&rawtime )  

    strcpy(times,asctime(timeinfo))  

    printf("\t所有学生上机费用如下:\n") 

    int i=1

    for(i=1i<=ni++)  {

        printf("学生%d费用:",i) 

        if((student[i-1].ontime[3]-48)*10+student[i-1].ontime[4]>(times[14]-48)*10+times[15]) 

            hours=(times[11]-48)*10+times[12]-(student[i-1].ontime[0]-48)*10-student[i-1].ontime[1]

        else 

            hours=(times[11]-48)*10+times[12]-(student[i-1].ontime[0]-48)*10-student[i-1].ontime[1]+1  

            printf("%d\n",hours)  

        } 

}  

//查询功能:按条件(班级、学号、姓名)显示学生的上机时间。 

void search()  { 

    int i,b,c,count

    do {

         char find[20]  

         printf("\n请选择查询方式:1.根据学号查询2.根据班级查询3.根据姓名查询4.根据上机时间:") 

         scanf("%d",&b) 

         switch(b) { 

             case 1: 

                 count=PF_FLOATING_POINT_PRECISION_ERRATA 

                 printf("\n**请输入学生的学号:") 

                 scanf("%s",find) 

                 for(i=0i<ni++)  {

                      if (strcmp(student[i].id,find)==0) {

                          count++  

                         if(count==PF_FLOATING_POINT_EMULATED) 

                         printf("学生学号\t学生班级\t学生姓名\t上机时间\n") 

                         printf("%8s%15s%15s%17s",student[i].id,student[i].theclass, student[i].name,student[i].ontime) 

                    } 

                } 

                if(!count) 

                    printf("****提示:该生不存在")

                goto A  

            case 2: 

                count=PF_FLOATING_POINT_PRECISION_ERRATA

                printf("\n**请输入学生的班级:")  

                scanf("%s",find) 

                for(i=0i<ni++)  { 

                    if (strcmp(student[i].theclass,find)==0)  { 

                        count++ 

                        if(count==PF_FLOATING_POINT_EMULATED)  

                            printf("学生学号\t学生班级\t学生姓名\t上机时间\n") 

                        printf("%8s%15s%15s%17s",student[i].id,student[i].theclass, student[i].name,student[i].ontime) }  }  

                        if(!count) 

                        printf("****提示:该生不存在") 

                        goto A 

            case 3: 

                count=PF_FLOATING_POINT_PRECISION_ERRATA 

                printf("\n**请输入学生的姓名:") 

                scanf("%s",find)  

                for(i=0i<ni++)  {  

                if (strcmp(student[i].name,find)==0)  {  

                    count++  

                if(count==PF_FLOATING_POINT_EMULATED)  

                    printf("学生学号\t学生班级\t学生姓名\t上机时间\n") 

                printf("%8s%15s%15s%17s",student[i].id,student[i].theclass, student[i].name,student[i].ontime) } }  

                if(!count) printf("****提示:该生不存在") 

                    goto A  

                case 4: 

                    count=PF_FLOATING_POINT_PRECISION_ERRATA  

                    printf("\n**请输入学生的上机时间:") scanf("%s",find)

                    for(i=0i<ni++) { 

                        if (strcmp(student[i].ontime,find)==0)  { 

                            count++  

                            if(count==PF_FLOATING_POINT_EMULATED) 

                            printf("学生学号\t学生班级\t学生姓名\t上机时间\n") 

                            printf("%8s%15s%15s%17s",student[i].id,student[i].theclass, student[i].name,student[i].ontime) 

                            } 

                    }  

                    if(!count) 

                    printf("****提示:该生不存在") 

                    goto A 

                    default:printf("*****提示:输入错误") 

                    }  

                A:printf("\n\t**1.继续\n\t**0.返回主菜单")  

                printf("\n\t 请输入您的选择:") 

                scanf("%d",&c) } 

                while(c) 

}

void menu() {  

    printf("\n\t*******************欢迎进入机房收费管理系统!*******************\n") 

    printf("\t* 1.录入功能2.计算功能*\n") printf("\t* 3.查询功能0.-*EXIT*- *\n") 

    printf("\t***************************************************************\n") 

    printf("\n\t 请输入您的选择:")

void main()  

    system("color 5f")

    int a 

    C:menu() 

    scanf("%d",&a)

    switch(a)  {  

    case 0:printf("***正在退出**谢谢使用本系统,再见")

        break

    case 1:addition()

     goto C 

    case 2:calculate()

     goto C /*浏览功能*/ 

    case 3:search() 

    goto C /*查询功能*/ }

}

听说回答的够长才能够自动采纳