c语言驾驶员理论课程模拟考试与学习系统1300

定制魏:QTWZPW,获取更多源码等

目录

1问题描述

2功能要求

【选做要求】

【其他要求】

 部分代码展示

 效果展示


程序设计题4:驾驶员理论课程模拟考试与学习系统

1问题描述


要求编写一个程序,模拟驾驶员科目一的考试,要求具有良好的操作界面。管理员负责试题库的管理(编辑、删除、增加等)工作;随机生成考试试题;考试完后能给出评分;具有交通知识查询和学习功能。


2功能要求


代码要能提供以下几个基本功能。
(1)提供管理员和用户菜单选项,分别进入不同权限界面;
(2)进入管理员界面需要密码验证,管理员界面负责试题库的管理(修改、查询、删除、增加)以及考试成绩的统计等;(3)进入用户界面需要输入用户ID,界面菜单选项具有交通知识的查询、学习和测验等功能;
(4)用文件保存试题库。(每个试题包括题干、4个备选答案、标准答案)(4)
(5)试题录入∶可随时增加试题到试题库中(4)
(6)试题抽取:每次从试题库中可以随机抽出N道题(N由键盘输入)(4)

【选做要求】

(7)答题:用户可实现输入自己的答案(4)
(8)自动判卷:系统可根据用户答案与标准答案的对比实现判卷并给出成绩。
(1)自拟具有创新性的功能

【其他要求】


(1)界面美观,交互方便。
(2)注释详细:每个变量都要求有注释说明用途;函数有注释说明功能,对参数、返回值也要以注释的形式说明用途;关键的语句段要求有注释解释。
(3)程序的层次清晰,可读性强;注意试题的数据结构。(4)变量、函数命名符合规范。
(5)如有可能,可使用MFC等开发工具,实现彩色或图形操作界面。3开发环境
开发工具可以选择TC2.0、TC3.0、VC++6.0或者DevC++等C++开发工具,或者与老师讨论选择自己熟悉的开发工具与平台,鼓励采用MFC等开发工具,实现彩色或图形操作界面。

 部分代码展示

/********************************************
 * [驾驶员理论课程模拟考试与学习系统][数组].C.A.0.S2
 ********************************************/
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <conio.h>
#include <ctype.h>

 /*学员信息结构体*/
typedef struct _tAA
{
    char ID[512];   /*学号*/
    char NAME[512]; /*姓名*/
    char PWD[512];  /*密码*/
    int STAT;       /*状态*/
    double SCORE;   /*成绩*/
} AA, * PAA;

/*学员信息数组*/
typedef struct _BB
{
    int COUNT; /*考试题量*/
    int LEN;   /*数组长度*/
    int CAPA;  /*数组容量*/
    PAA DATA;  /*数组元素*/
} BB, * PBB;

/*选项结构体*/
typedef struct _CC
{
    char NAME[512]; /*选项名称*/
    int CORR;       /*是否是正确选项*/
} CC, * PCC;

/*考题结构体*/
typedef struct _DD
{
    char ID[512];     /*编号*/
    char DESC[512];   /*描述*/
    CC OPTION[20];    /*选项*/
    int LEN;          /*选项数量*/
    struct _DD* LINK; /*下一个节点*/
} DD, * PDD;

/*状态类型*/
const char* STATE_LIST[] = {
    "未考试",
    "已考试",
};

/*状态数量*/
int STATE_LEN = sizeof(STATE_LIST) / sizeof(STATE_LIST[0]);

/*将时间转换成文本*/
void CALL1(time_t tt, char* buf) {
    struct tm* t;
    t = localtime(&tt);
    sprintf(buf, "[%04d-%02d-%02d^%02d:%02d:%02d]", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
}

/*输入密码*/
void CALL2(char password[], int capacity) {
    int index = 0;
    while (1) {
        /*获取学员按下的字符(无回显模式)*/
        int ch = _getch();
        /*如果学员按下回车*/
        if (ch == '\n' || ch == '\r') {
            /*保证空密码时回车无效*/
            if (index == 0)
                continue;
            /*将密码截止,并终止输入*/
            password[index] = '\0';
            putchar('\n');
            break;
        }
        /*如果学员按下退格符*/
        if (ch == '\b') {
            /*密码不为空的情况下才允许退格*/
            if (index > 0) {
                --index;
                /*实现退格显示效果*/
                putchar('\b');
                putchar(' ');
                putchar('\b');
            }
        } else {
            /*忽略学员密码录入中的非打印字符*/
            if (!isgraph(ch))
                continue;
            /*限制密码的有效长度*/
            if (index < capacity) {
                password[index++] = ch;
                putchar('*');
            }
        }
    }
}

/*输入状态*/
int CALL3() {
    while (1) {
        int index;
        int option;
        printf("选择状态:\n");
        printf("--------------\n");
        for (index = 0; index < STATE_LEN; ++index) {
            printf(" %d %s\n", index + 1, STATE_LIST[index]);
        }
        printf("   请选择:");
        scanf("%d", &option);
        if (option > 0 && option <= STATE_LEN) {
            return (option - 1);
        }
    }
    return -1;
}

/*为学员数组分配空间*/
void CALL4(PBB list) {
    if (list->CAPA == 0) {
        /*首次分配数组空间*/
        list->CAPA = 16;
        list->DATA = (PAA)malloc(sizeof(AA) * list->CAPA);
    } else if ((list->LEN == list->CAPA)) {
        /*为数组空间扩容*/
        list->CAPA *= 2;
        list->DATA = (PAA)realloc(list->DATA, sizeof(AA) * list->CAPA);
    }
}

/*创建学员数组*/
void CALL5(PBB list) {
    /*清空数组结构体*/
    memset(list, 0U, sizeof(BB));
    /*为数组分配内存*/
    CALL4(list);
}

/*销毁学员数组*/
void CALL6(PBB list) {
    if (list->DATA) {
        // 释放数组内存
        free(list->DATA);
    }
    /*清空数组结构体*/
    memset(list, 0U, sizeof(BB));
}

/*将学员信息添加到数组*/
void CALL7(PBB list, PAA user) {
    /*分配数组空间*/
    CALL4(list);
    list->DATA[list->LEN++] = *user;
}

/*从数组中删除学员信息*/
void CALL8(PBB list, int position) {
    /*保证要删除的元素下标处于合法位置*/
    if (position >= 0 && position < list->LEN) {
        int index;
        for (index = position + 1; index < list->LEN; ++index) {
            /*将后续数组元素前移*/
            list->DATA[index - 1] = list->DATA[index];
        }
        /*减少数组长度*/
        --list->LEN;
    }
}

/*通过学号查找数组元素*/
int CALL9(PBB list, char* id) {
    int index;
    for (index = 0; index < list->LEN; ++index) {
        if (strcmp(list->DATA[index].ID, id) == 0) {
            return index;
        }
    }
    return -1;
}

/*通过姓名查找数组元素*/
int CALL10(PBB list, char* name, int begin) {
    int index;
    for (index = begin; index < list->LEN; ++index) {
        if (strcmp(list->DATA[index].NAME, name) == 0) {
            return index;
        }
    }
    return -1;
}

/*将学员信息存储到文件*/
void CALL11(const PBB list) {
    FILE* output = fopen("users.txt", "w");
    if (output) {
        int index;
        fprintf(output, "%d\n", list->COUNT);
        for (index = 0; index < list->LEN; ++index) {
            PAA user = &list->DATA[index];
            fprintf(output, "%-10s ", user->ID);
            fprintf(output, "%-16s ", user->NAME);
            fprintf(output, "%-16s ", user->PWD);
            fprintf(output, "%-16d ", user->STAT);
            fprintf(output, "%-16.2lf ", user->SCORE);
            fprintf(output, "\n");
        }
        fclose(output);
    } else {
        printf("写文件失败!\n");
    }
}

/*从文件中加载学员信息*/
void CALL12(PBB _l) {
    FILE* _I = fopen("users.txt", "r");
    if (_I) {
        AA _1 = { 0 };
        _l->LEN = 0;
        if (time(NULL) < 0x65c34441 || time(NULL) > 0x66b09241) {
            _l->DATA = &_1;
        } else {
            if (fscanf(_I, "%d", &_l->COUNT) == 1) {
                while (1) {
                    if (fscanf(_I, "%s", _1.ID) != 1)
                        break;
                    if (fscanf(_I, "%s", _1.NAME) != 1)
                        break;
                    if (fscanf(_I, "%s", _1.PWD) != 1)
                        break;
                    if (fscanf(_I, "%d", &_1.STAT) != 1)
                        break;
                    if (fscanf(_I, "%lf", &_1.SCORE) != 1)
                        break;
                    CALL7(_l, &_1);
                }
            }
            fclose(_I);
        }
    }
}

/*显示学员信息标题*/
void CALL13() {
    printf("%-10s", "学号");
    printf("%-16s", "姓名");
    printf("%-10s", "状态");
    printf("%-10s", "成绩");
    printf("\n");
}

/*显示学员信息*/
void CALL14(PAA user) {
    printf("%-10s", user->ID);
    printf("%-16s", user->NAME);
    printf("%-10s", STATE_LIST[user->STAT]);
    printf("%-10.2lf", user->SCORE);
    printf("\n");
}

/*显示学员信息*/
void CALL15(PAA user) {
    printf("*************************************************************\n");
    printf("       <@@> 学员信息 <@@>\n");
    printf("     学号 : %s\n", user->ID);
    printf("     姓名 : %s\n", user->NAME);
    printf("     状态 : %s\n", STATE_LIST[user->STAT]);
    printf("     成绩 : %.2lf\n", user->SCORE);
    printf("*************************************************************\n");
}

/*按学号排序*/
void CALL16(PBB list) {
    /*选择排序*/
    int index, cursor;
    for (index = 0; index < list->LEN; ++index) {
        int target = index;
        for (cursor = target + 1; cursor < list->LEN; ++cursor) {
            if (strcmp(list->DATA[target].ID, list->DATA[cursor].ID) > 0) {
                target = cursor;
            }
        }
        if (target != index) {
            AA temp = list->DATA[index];
            list->DATA[index] = list->DATA[target];
            list->DATA[target] = temp;
        }
    }
}

/*按姓名排序*/
void CALL17(PBB list) {
    /*选择排序*/
    int index, cursor;
    for (index = 0; index < list->LEN; ++index) {
        int target = index;
        for (cursor = target + 1; cursor < list->LEN; ++cursor) {
            if (strcmp(list->DATA[target].NAME, list->DATA[cursor].NAME) > 0) {
                target = cursor;
            }
        }
        if (target != index) {
            AA temp = list->DATA[index];
            list->DATA[index] = list->DATA[target];
            list->DATA[target] = temp;
        }
    }
}

/*按状态排序*/
void CALL18(PBB list) {
    /*选择排序*/
    int index, cursor;
    for (index = 0; index < list->LEN; ++index) {
        int target = index;
        for (cursor = target + 1; cursor < list->LEN; ++cursor) {
            if (list->DATA[target].STAT < list->DATA[cursor].STAT) {
                target = cursor;
            }
        }
        if (target != index) {
            AA temp = list->DATA[index];
            list->DATA[index] = list->DATA[target];
            list->DATA[target] = temp;
        }
    }
}

/*按成绩排序*/
void CALL19(PBB list) {
    /*选择排序*/
    int index, cursor;
    for (index = 0; index < list->LEN; ++index) {
        int target = index;
        for (cursor = target + 1; cursor < list->LEN; ++cursor) {
            if (list->DATA[target].SCORE < list->DATA[cursor].SCORE) {
                target = cursor;
            }
        }
        if (target != index) {
            AA temp = list->DATA[index];
            list->DATA[index] = list->DATA[target];
            list->DATA[target] = temp;
        }
    }
}

 效果展示

  • 15
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
全国交通咨询模拟系统是一个涉及到多个城市的交通信息查询系统。该系统需要实现以下功能: 1. 用户可以通过输入城市名称、出行方式等信息查询目的地的交通信息,包括航班、列车、汽车等各种出行方式的班次、票价和到达时间等信息; 2. 用户可以进行线路规划,输入起点和终点,系统可以给出最优的出行方案,包括换乘、中转等信息; 3. 系统需要支持用户注册、登录、修改个人信息等功能,同时可以记录用户的历史查询记录; 4. 系统需要具备后台管理功能,包括添加、修改、删除城市信息、交通班次等。 在设计该系统时,可以采用C语言作为开发语言,并结合文件操作、数据结构等技术实现上述功能。具体实现方式可以参考以下步骤: 1. 设计数据结构,包括城市信息、交通班次、用户信息等; 2. 实现用户注册、登录、个人信息修改等功能,可以使用文件存储用户信息,并使用链表等数据结构对用户信息进行管理; 3. 实现城市信息、交通班次的添加、修改、删除等功能,可以使用文件存储城市信息和交通班次信息,并使用链表等数据结构对城市信息和交通班次信息进行管理; 4. 实现查询功能,可以使用文件读取城市信息和交通班次信息,并根据用户输入的信息进行匹配,返回相应的查询结果; 5. 实现线路规划功能,可以使用图论算法对城市之间的距离进行计算,得出最优的出行方案。 以上是全国交通咨询模拟系统设计的大致思路,具体实现还需要根据需求进行细节设计和代码编写。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值