四六级考试评分程序
2015-12-09 19:01
295 查看
#include<iostream> #include<cstring> #include<stdlib.h> #include<time.h> #define MAXSIZE 55 //选择题的数量 #define MAXSIZE2 60 //卷子的数量 using namespace std; float count; //计数 int main() { cout<<" * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl; cout<<" * 试卷说明: *"<<endl; cout<<" * 共65道选择题,其中1~25为听力,每题7.1分; *"<<endl; cout<<" * 26~35为完型填空,每题3.55分; *"<<endl; cout<<" * 36~45为快速匹配,每题7.1分; *"<<endl; cout<<" * 46~55为阅读,每题14.2分; *"<<endl; cout<<" * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl; int i,k,score; char a[MAXSIZE+1],b[MAXSIZE+1]; count=0.0;k=1; srand((unsigned)time(0)); //时间不同,产生的种子也不同 FILE *fp=fopen("d:\\siliuji.txt","w"); //生成随机标准答案 char str[17]="Z"; char *p; int y=1; for(i=0;i<55;i++) { if(i>=35&&i<=44) a[i]=rand()%12+65; else if(i>=25&&i<=34) { while(1) { a[i]=rand()%15+65; p=strchr(str,a[i]); //检测生成的答案是否重复 if(!p) { str[y++]=a[i]; break; } } } else a[i]=rand()%4+65; } //输出标准答案 for(i=0;i<55;i++) { fprintf(fp,"%c ",a[i]); cout<<a[i]<<" "; if((i+1)%11==0) { fprintf(fp,"\n"); cout<<endl; } } fprintf(fp,"\n"); cout<<endl; //循环生成60套试卷 while(k<=60) { count=0; score=0; char string[17]="Z"; char *ptr; int x=1; //生成55道选择题,并与标准答案进行比对 for(i=0;i<55;i++) { if(i>=35&&i<=44) b[i]=rand()%12+65; else if(i>=25&&i<=34) { while(1) { b[i]=rand()%15+65; ptr=strchr(string,b[i]); if(!ptr) { string[x++]=b[i]; break; } } } else b[i]=rand()%4+65; if(b[i]==a[i]) { count++; if(i>=25&&i<=34) score+=3.55; else if(i>=45) score+=14.2; else score+=7.1; } } //结果输出 for(i=0;i<55;i++) { fprintf(fp,"%c ",b[i]); cout<<b[i]<<" "; if((i+1)%11==0) { fprintf(fp,"\n"); cout<<endl; } } fprintf(fp,"第%d套卷子的正确率为:%f%\n",k,(count/55)*100); cout<<"第"<<k++<<"套卷子的正确率为:"<<((float)count/55)*100<<"%"<<endl; fprintf(fp,"分值为:%d\n",score); cout<<"分值为:"<<score<<endl; cout<<endl; } system("pause"); return 0; }
相关文章推荐
- 古典问题
- Chromium Graphics Update in 2014(滑动)
- 公司初创时期的技术路线系列--4.dubbo安装与配置
- ORACLE连接数
- Unity3d的电脑AI以及自动寻路
- 【LEETCODE】240-Search a 2D Matrix II
- Java解析XML的四种方法详解
- 2014 十大工具
- iOS用if语句判断null
- Stream API:创建Stream
- 多位水仙花数算法
- 一、C语言(基本概念)
- C#调用C++ DLL的方法
- project euler 67
- 由于文件组 'PRIMARY 中的磁盘空间不足,无法为数据库 'newnet' 分配新页。请删除文件组中的对象、将其他文件添加到文件组或者为文件组中的现有文件启用自动增长,以便增加必要的空间。
- win7 64位 CUDA7.5 VS2013 安装配置
- SpannableString与SpannableStringBuilder
- SQL阻塞原因造成系统多功能无响应的分析解决思路
- 文本输入框,只能显示内容而不能修改
- [转]蚁群算法、遗传算法、模拟退火算法