| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2504 人关注过本帖, 1 人收藏
标题:随机选题考试系统
取消只看楼主 加入收藏
xs_cctv
Rank: 1
来 自:湖南
等 级:新手上路
帖 子:21
专家分:0
注 册:2008-8-19
结帖率:100%
收藏(1)
 问题点数:0 回复次数:0 
随机选题考试系统
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#define N 50
int n=0;    //实际参考人数
struct Info     //定义最大参考人数的结构数组
{
    int count;      //用于答对题数计数器
    int overall;    //总分
    char num[6+1];       //存储ID号
    char name[20];  //存储姓名
}Information[20];
struct problem            //定义题目结构数组
{
    int Id;                //题目编号
    char subject[200];        //题目
    char select[200];        //题目选项
    char right;                //正确答案
}pro[N]={                                            //结构变量初始化
    {1,"找出下列数字的规律,选择填空()  1  4  13  40  ()  364.",
        "A.53   B.81  C.121  D.243",'C'},
    {2,"Where () you come from ?","A.are   B.is  C.have  D.has",'A'},
    {3,"若池塘中的荷花每天长满的与前天的一样多,当第十天时已长满了半个池塘,    请问长满整个池塘需要多久?","A.20   B.21  C.10   D.11",'D'},

    {4,"请问\"林字多一半\"是什么字?","A.森   B.林  C.木  D.梦",'D'},
    {5,"中国历史上第一个女皇帝是()?","A. 孝庄  B.武则天  C.慈禧  D.杨贵妃",'B'},
    {6,"已知A的ASCII码为65,则ASCII码为70的字符是:.","A. C    B. D   C. F   D. G",'C'},
    {7,"()发现了万有引力.","A.贝尔   B.牛顿  C.史蒂芬森  D.霍金",'B'},
    {8,"已知M比P 高,O比p高,比N低,下列判断正确的是:.","A.M>O   B.O>N  C.N>M  D.N>P",'D'},
    {9,"小民第一天上学,和班里的每一位同学握一次手,一共握了30次,请问小民班有多少人?",
    "A.30   B.31  C.60  D.61",'B'},
    {10,"一只猴子某天摘了n个桃子,当天(第一天)吃了一半零一个,以后每天吃掉所剩桃的一半零一个    到第5天时猴子发现只剩下一个桃了,请问n 的值是?","A.94   B.46  C.22  D.10",'B'},

    {11,"在下面各世界顶级的奖项中,为计算机科学与技术领域作出杰出贡献的科学家设立的奖项是?","A.沃尔夫奖   B.诺贝尔奖   C.菲尔兹奖   D.图灵奖",'D'},
    {12,"哈雷慧星多少年出现一次?","A.75年   B.76年   C.77年   D.78年",'B'},
    {13,"“初唐四杰”中有:","A.王绩    B.王勃    C.王维   D.王之焕",'B'},
    {14,"电话的发明者是:","A.爱迪生    B.贝尔    C.贝尔德    D.诺贝尔",'B'},
    {15,"“世界环境日”是:","A.3月5日 B.4月5日 C.5月5日   D.6月5日",'D'},
    {16,"“敖包相会”中的“敖包”是:","A.小土山     B.蒙古包     C石堆     D.河流",'C'},
    {17,"诗句“每逢佳节倍思亲”中的“佳节”原意是指:","A.元宵节     B.重阳节      C.中秋节     D.端午节",'B'},
    {18,"汉字“单”共有几种读音:","A.1种     B.2种     C.3种      D.4种",'C'},
    {19,"被称为“画圣”的是:","A.顾恺之   B.吴道子   C.郑板桥   D.齐白石",'B'},
    {20,"著名雕塑作品《思想者》出于谁之手:","A.米开朗基罗    B.罗丹      C.米隆    D.达芬奇",'B'},
    {21,"“耳顺”代指什么年纪?","A.四十岁      B.五十岁   C.六十岁    D.七十岁",'C'},
    {22,"“阿凡提”在新疆维吾尔族语里是什么意思?","A.善良的人    B.机智的人   C.有学问的人   D.朋友多的人",'B'},
    {23,"1秒等于:","A.60微秒  B.100微秒    C.120微秒     D.1000微秒",'D'},
    {24,"“海上升明月,天涯共此时”是谁的诗句?","A.王勃     B.张九龄    C.白居易        D.李白",'B'},
    {25,"书画作品中的“四君子”是指哪四种植物?","A.梅、兰、竹、菊    B.梅、松、竹、兰    C.梅、荷、兰、菊    D.4、兰、荷、菊",'A'},
    {26,"《义勇军进行曲》是哪部电影的主题歌?","A.《塞上风云》    B.《十字街头》    C.《风云儿女》    D.《大路》",'C'},
    {27,"诺贝尔奖最后设立的奖项是:","A.和平奖      B.经济学奖        C.化学奖     D.文学奖",'B'},
    {28,"人的舌头的哪个部位对苦味最敏感?","A.舌尖     B.舌两侧      C.舌根     D.舌中间",'C'},
    {29,"我国信用卡透支期限最长为:","A.6天     B.16天    C.60天     D.90天",'C'},
    {30,"海豚为什么要追随轮船呢?","A.寻求安全保障    B.可以获取食物  C.借助外力游动  D.与人类嬉戏",'C'},
    {31,"我国法律所称的老人是指年龄大于:","A.55岁的公民  B.60岁的公民  C.65岁的公民  D.70岁的公民",'A'},
    {32,"我们常吃的辣椒属于什么类蔬菜?","A.叶菜类      B.茄果类      C.瓜菜类      D.水生菜类",'B'},
    {33,"世界上面积最大的宫殿是:","A.克里姆林宫      B.爱丽舍宫    C.故宫     D.白宫",'C'},
    {34,"下列矿物质中,属于人体微量元素的有:","A.钙       B.钠       C.钾       D.铁",'C'},
    {35,"我国55个少数民族中,人口最多的是什么族?","A.满族 B.苗族    C.黎族  D.壮族",'D'},
    {36,"漫画起源于哪个国家?","A.日本     B.法国     C.英国     D.中国",'D'},
    {37,"举办“戛纳电影节”的戛纳是:","A.法国城市     B.意大利城市      C.英国城市        D.摩纳哥城市",'A'},
    {38,"经常食用哪种食物容易引起铅中毒?","A.土豆     B.竹笋     C.松花蛋   D.酸菜鱼",'C'},
    {39,"有奖销售的最高奖金额不得超过:","A.1000元  B.2000元  C.5000元  D.10000元",'C'},
    {40,"全国助残日是每年五月的:","A.第1个周日  B.第2个周日  C.第3个周日  D.第4个周日",'C'},
    {41,"偃旗息鼓“偃”的意思是:","A.摘下     B.收起     C.停止     D.放倒",'D'},
    {42,"“跬步千里”中“跬步”指:","A.半步     B.一小步   C.一步     D.大一步",'A'},
    {43,"成语“沐雨栉风”源于哪个故事?","A.苏武牧羊    B.大禹治水     C.赤壁之战    D.安史之乱",'B'},
    {44,"“入木三分”这个典故原意用来形容:","A.雕刻技术高  B.文章深刻    C.书法笔力强劲    D.射箭本领高",'C'},
    {45,"任何一支足球队在比赛中的人数少于几名时,该场比赛应为无效?","A.5    B.6     C.7    D.8",'B'},
    {46,"世界杯足球赛始于哪一年?","A.1906年      B.1918年      C.1930年      D.1942年",'C'},
    {47,"西方著名作曲家中被称为“交响乐之父”的是:","A.海顿     B.莫扎特   C.贝多芬   D.舒伯特",'A'},
    {48,"古时“文章”一词可指什么?","A.彩色的条纹图案    B.泛指文字  C.寺庙里的经文   D.歌谱",'A'},
    {49,"一般被誉为“艺术之母”的是:","A.绘画     B.戏剧     C.雕塑     D.舞蹈",'D'},
    {50,"《水浒传》的第三回“鲁提辖拳打镇关西”,第二拳打在郑屠的:","A.鼻子上   B.眼睛上   C.太阳穴上    D.胸口上",'B'},
};
void shouye();                //首页
void yejiao();                //页脚
void Interface();            //界面
void into();                //登录
void theme();                //选题
void sum();                 //总分
void displays();            //显示所有参考人员信息
void IntoExam();            //进入考试
void sort();                //对结果排序
void select();              //查询成绩
void ExamInformation();        //显示考试的最后信息
void exit();       
void main()                    //主函数
{
    char ch='y';            //控制循环
    int xz;
    shouye();
    do
    {
        system("cls");        //清屏
        system("color 1f");    //颜色
        system("date /t");    //日期
        system("time/t");    //时间
        printf("\n\n\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n");
        printf("\t\t||    ☆1、登录进入考题系统           ||\n");
        printf("\t\t||    ☆2、显示所有参考人员信息       ||\n");
        printf("\t\t||    ☆3、对所有参考人员的成绩排序   ||\n");
        printf("\t\t||    ☆4、查询成绩                   ||\n");
        printf("\t\t||    ☆5、显示考试信息               ||\n");
        printf("\t\t||    ☆6、退出                       ||\n");
        printf("\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n\n");
        printf("请选择:\n");
        yejiao();
        fflush(stdin);
        scanf("%d",&xz);
        fflush(stdin);
        switch(xz)
        {
            case 1 :IntoExam();break;
            case 2 :displays();break;
            case 3 :sort();break;
            case 4 :select();break;
            case 5 :ExamInformation();break;
            case 6 :exit();
            default :printf("输入错误!\n");
        }
        if(xz==6)
        {
            exit();
            break;
        }
        system("cls");
        printf("是否返回主菜单?(y/n)\n");
        fflush(stdin);
        yejiao();
        scanf("%c",&ch);
        getchar();
        system("cls");
        fflush(stdin);
    }while(ch=='y');
}
void shouye()
{
    printf("\n\n\t                                                        \n\n");
    system("color 1f");
    printf("\t¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n");
    printf("\t¤                                                        ¤\n");
    printf("\t¤          欢 迎 使 用 随 机 选 题 考 试 系 统           ¤\n");
    printf("\t¤                                                        ¤\n");
    printf("\t¤                                                        ¤\n");
    printf("\t¤                                                        ¤\n");    
    printf("\t¤                                                              ¤\n");
    printf("\t¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n\n");    
    printf("按ENTER键进入下一界面...---->");
    getchar();
}
void IntoExam()            //进入考试
{
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    char ch='y',enter;
    fflush(stdin);
            do
            {
            Interface();        //界面
            printf(" 按ENTER键进入登录系统...-->");
            fflush(stdin);
            scanf("%c",&enter);
            into();            //登录
            printf(" 按ENTER键进入电脑随机选题系统...-->");
            fflush(stdin);
            scanf("%c",&enter);
            theme();        //选题
            sum();            //算得分
            fflush(stdin);
            printf("是否继续另一人的考试?(y/n)\n\n\n");
            yejiao();
            fflush(stdin);
            scanf("%c",&ch);
            fflush(stdin);
            n++;        //实际参考人数+1
        }while(ch=='y');
}
void Interface()        //界面
{
    system("cls");
    system("date/t");
    system("time/t");
    system("color 1f");
    printf("\n\n\n      жжжжжжжжжжжжжжжжжжжжжжжжжжж\n");
    printf("    ж                 * * * *    * * * *                   ж\n");
    printf("    ж               *         * *         *                ж\n");
    printf("    ж               *   欢迎进入考题系统  *                ж\n");
    printf("    ж               *                     *                ж\n");
    printf("    ж                 *                 *                  ж\n");
    printf("    ж                    *            *                    ж\n");
    printf("    ж                        *     *                       ж\n");
    printf("    ж                           *                          ж\n");    
    printf("      жжжжжжжжжжжжжжжжжжжжжжжжжжж\n\n\n");
    yejiao();
}
void into()        //登录
{
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    int j;
    do
    {
        printf("\n请输入你的ID号:(限一个六位数字)");
        scanf("%s",Information[n].num);
        Information[n].num[7]='\0';
        if(strlen(Information[n].num)!=6)        //判断ID号是否为六位
        {
            printf("\n输入错误,请重新输入!\n");
        }
        else
        {
            for(j=0;j<n;j++)
            {
                if(strcmp(Information[n].num,Information[j].num)==0) //判断ID号是否有相同的
                    break;
            }
            if(j<n)
            {
                printf("\n该ID号已使用,请核对后重新输入.\n");
            }
            else
            {
                break;
            }
        }
    }while(j<n);
    printf("\n");
    do
    {
        printf("请输入你的姓名:");
        fflush(stdin);
        scanf("%s",Information[n].name);
        for(j=0;j<n;j++)
        {
            if(strcmp(Information[n].name,Information[j].name)==0)    //判断是否有相同的姓名
            {
                break;
            }
        }
        if(j<n)
        {
            printf("该考生已参加过一次,不能再次参加考试.\n");
            printf("请核对后重新输入.\n");
        }
        else
            break;
    }while(j<n);//控制条件(如果有相同的姓名,则重新输入)
        yejiao();
}
void theme()                //选题
{
    system("cls");
    system("color 1f");
    system("date/t ");
    system("time/t");
    int j,i,k,m=0,a[10];    //k是随机数,m是用于计算产生不同随机数的个数,a数组用于存储产生的题号
    char answer;            //你的选择
    printf("题目已选出,请依次答题(答对一题得十分,答错或不答得零分)\n");
    printf("****注意:本次一共生成10道题,每题10分,满分100分***\n\n");
    do
    {
        printf("    ******随机产生第%d道题目******\n",m+1);
        srand((unsigned)time(NULL));        //保证每次运行产生不同的随机序列
        k=(rand()%100+2)/2;
        for(j=0;j<m;j++)
        {
            if(k==a[j])            //若产生的随机数有相同的,则跳出
                break;
        }
        if(j>=m)    
        {    
            a[m]=k;            //若产生的随机数不相同,则将该数存储在a数组中        
            for(i=0;i<N;i++)
            {
                if(a[m]==pro[i].Id)    //查找与该随机数相同的题号
                {
                    printf("\n%d%s\n%s\n ",pro[i].Id,pro[i].subject,pro[i].select);//打印出题目及选项
                    printf("请输入你的答案\n");
                    fflush(stdin);
                    scanf("%c",&answer);
                    if(answer==pro[i].right)
                    {
                        Information[n].count++;    //若你的答案与正确答案相同,则你的答对题数+1
                        printf("                @@@@@@@@@@\n");
                        printf("        *** *** r i g h t *** ***       \n" );
                        printf("                @@@@@@@@@@\n\n");
                        getchar();
                    }
                    else
                    {
                        printf("               XXXXXXXXX\n");
                        printf("       *** *** w r o n g *** ***        \n");
                        printf("               XXXXXXXXX\n\n");
                        getchar();
                    }
                        break;    //如果找到与该随机数相同的题号,就跳出
                }
                else
                    continue;//否则就继续查找
            }
            m++;        //产生的不同的随机数+1            
        }
    }while(m<10);        //控制产生10个不同的随机数
    yejiao();
}
void sum()            //总分
{
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    Information[n].overall=Information[n].count*10;    //算得分
    if(Information[n].overall>=60)
    {
        printf("\n\t          ~~~~~~~~~~     ");
        printf("\n\t★★★★★恭喜你,你通过了考试!★★★★★\n");
        printf("    \t      ~~~~~~~~~~     \n");
        printf("\t****************************************\n\n");
        printf("\t#####您的得分是%d分#####\n\n",Information[n].overall);

    }
    else
    {
        printf("\n\t          ~~~~~~~~~~     ");
        printf("\n\t☆☆☆☆☆革命尚未成功,同志仍需努力!☆☆☆☆☆\n");
        printf("\t          ~~~~~~~~~~     \n");
        printf("\t****************************************\n\n");
        printf("\t####您的得分是%d分####\n",Information[n].overall);
    }
    yejiao();
    getchar();
    system("cls");

}

void displays()            //显示所有参考人员的信息
{
    int j;
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    printf("\t所有参考人员的信息如下:\n");
    printf("\t\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
    printf("\t\t§\t姓名\t考号\t得分\t§\n");
    for(j=0;j<n;j++)
    {
        printf("\t\t§\t%s",Information[j].name);
        printf("\t");
        printf("%s ",Information[j].num);
        printf("\t");
        printf("%d\t§\n",Information[j].overall);
    }
    printf("\t\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
    yejiao();
    getchar();
}
void sort()        //根据成绩排序
{
    int i,j;
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    struct Info Informations;    //用于交换的中间量
    //以下是冒泡排序算法
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(Information[j+1].overall>Information[j].overall)
            {
                Informations=Information[j+1];
                Information[j+1]=Information[j];
                Information[j]=Informations;
            }
        }
    
    }
    printf("对成绩排序后的结果如下:\n");        //打印排序后的结果(由大到小)
    printf("\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
    printf("\t§\t姓名\t考号 \t得分\t§\n");
    for(j=0;j<n;j++)
    {
    printf("\t§\t%s",Information[j].name);
    printf("\t");
    printf("%s ",Information[j].num);
    printf("\t");
    printf("%d\t§\n",Information[j].overall);
    fflush(stdin);
    }
    printf("\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
    yejiao();
    getchar();
}
void select()        //查询
{
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    int j;
    char nums[6+1];                //考号
    char xingming[20];            //姓名
    int xz;
    char ch='y';            //控制循环是否继续
    do
    {
        printf("请输入你的某一信息:\n");
        printf("\n\n\t\t★★★★★★★★★★★★★★★★★\n");
        printf("\t\t★    △1、考号      ★\n");
        printf("\t\t★    △2、姓名             ★\n");
        printf("\t\t★★★★★★★★★★★★★★★★★\n\n");
        printf("请选择:\n\n\n");
        fflush(stdin);
        yejiao();
        scanf("%d",&xz);
        getchar();
        system("cls");
        fflush(stdin);
        switch(xz)            //选择功能后,实现功能
        {
        case 1 :    //根据ID号进行查找算法
            {
                do
                {
                    printf("\n请输入你的ID号:(限一个六位数字)");
                    scanf("%s",nums);
                    nums[7]='\0';
                    if(strlen(nums)==6)        //判断ID号是否为六位数
                    {
                        for(j=0;j<n;j++)        //查找ID号相同的考生
                        {
                            if(strcmp(Information[j].num,nums)==0)
                                break;
                        }
                        break;
                    }
                    else
                    {
                        printf("输入错误,请重新输入.\n");
                    }
                    }while(strlen(nums)==6);
                        if(j<n)            //如果找到了,则输出
                        {
                            printf("查询的结果如下:\n");
                            printf("\t\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
                            printf("\t\t§\t姓名\t考号 \t得分\t§\n");
                            printf("\t\t§\t%s",Information[j].name);
                            printf("\t");
                            printf("%s ",Information[j].num);
                            printf("\t");
                            printf("%d\t§\n",Information[j].overall);    
                            printf("\t\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
                        }
                        else
                            printf("没有找到该ID号!");
                }
            break;
        case 2 :        //根据姓名进行查找算法
            {
                printf("请输入你的姓名:\n");
                fflush(stdin);
                scanf("%s",xingming);
                fflush(stdin);
                for(j=0;j<n;j++)        //查找姓名相同的考生
                {
                    if(strcmp(xingming,Information[j].name)==0)
                        break;
                }
                if(j<n)
                {
                    printf("\t查询的结果如下:\n");
                    printf("\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
                    printf("\t§\t姓名\t考号 \t得分\t§\n");
                    printf("\t§\t%s",Information[j].name);
                    printf("\t");
                    printf("%s ",Information[j].num);
                    printf("\t");
                    printf("%d\t§\n",Information[j].overall);
                    printf("\t§☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆§\n");
                }
                else
                    printf("没有找到该姓名!");        
            }
            break;
        default :printf("请在1与2之间选择!\n");
        }
        printf("\n是否继续查询?(y/n)\n");
        fflush(stdin);
        yejiao();
        scanf("%c",&ch);
        fflush(stdin);
        system("cls");
    }while(ch=='y');
}
void ExamInformation()            //显示考试信息
{
    system("cls");
    system("color 1f");
    system("date/t");
    system("time/t");
    int i;
    float excellence=0;        // 用于统计优秀人数
    float pass=0;                //用于统计及格人数
    float all=0;                //用于计算本次考试的总分
    float average;            //用于计算本次考试的平均成绩
    float exces,passes;
    for(i=0;i<n;i++)
    {
        if(Information[i].overall>=90)
            excellence++;            //统计优秀人数
        else
            continue;
    }
    for(i=0;i<n;i++)
    {
         if(Information[i].overall>=60)
            pass++;                      // 统计及格人数
        else
            continue;
    }
    for(i=0;i<n;i++)
    {
        all+=Information[i].overall;        //用累加的方法求本次考试的总分
    }
    exces=excellence/n;                //求优秀率
    passes=pass/n;                            //求及格率
    average=all/n;                            //求本次考试的平均分
    printf("\t*********************************************\n");
    printf("\n\t\t本次考试的详细信息如下:\n\n");
    printf("\t\t参考人数(人):%d\n",n);
    printf("\t\t优秀人数(人):%.0f,优秀率:%.2f /100 \n",excellence,exces*100);
    printf("\t\t及格人数(人):%.0f,及格率:%.2f /100 \n",pass,passes*100);
    printf("\t\t本次考试平均分是%.2f分。\n",average);
    printf("\t*********************************************\n\n");
    yejiao();
    getchar();
}
void yejiao()                //相当于页脚
{
    printf("\n\n\t\t   ¤                                                 ¤\n\n");
    printf("\t\t**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**Ψ**\n\n");
}
void exit()                //退出
{
    system("cls");
    system("date/t");
    system("time/t");
    printf("\n\n\t                                          \n\n");
    printf("            \t     欢迎再次使用!\n");
    printf("\n                \t Bye-Bye\n\n\n");
    yejiao();

}
搜索更多相关主题的帖子: 考试 系统 随机 选题 
2008-09-18 19:56
快速回复:随机选题考试系统
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043616 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved