小学生算术能力测试系统
2016-03-23 22:15
363 查看
/*
*2015 烟台大学计算机与控制工程学院
*文件名称: 小学生算术能力测试系统
*作者:马康泰
*完成日期 :2016年3月12日
*版本号;
小学生算术能力测试系统
设计一个程序,用来实现帮助小学生进行算术运算练习,它具有以下功能:提供 10道加、
减、乘、除四种基本算术运算的题目,每道题中的操作数是随机产生的,且操作数不超过 2位
数的正整数;练习者根据显示的题目输入自己的答案,程序自动判断输入的答案是否正确并显
示出相应的信息。最后显示做对了几道题*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main( )
{
int iRight=0;
int i,iFuhao;
double dZheng,n1,n2;
for(i=0;i<10;i++)
{
srand(time(0));
iFuhao = rand()%4;
n1=rand()%100;
n2=rand()%100;
switch(iFuhao)
{
case 0:cout <<n1<<'+'<<n2<<'=';dZheng=n1+n2;break;
case 1:cout <<n1<<'-'<<n2<<'=';dZheng=n1-n2;break;
case 2:cout <<n1<<'*'<<n2<<'=';dZheng=n1*n2;break;
case 3:dZheng=n1/n2;
if(dZheng==(int)dZheng)
{cout <<n1<<'÷'<<n2<<'=';break;}
else
{
i--;
continue;
}
}
int dShu;
cin >> dShu;
if(dShu==dZheng)
{
cout<<"Right"<<endl;
iRight++;
}
else
{
cout<<"Error Right="<<dZheng<<endl;
}
}
cout << "共做对"<<iRight<<"道,"<<"得分"<<iRight*10<<"分。"<<endl;
return 0;
}
*2015 烟台大学计算机与控制工程学院
*文件名称: 小学生算术能力测试系统
*作者:马康泰
*完成日期 :2016年3月12日
*版本号;
小学生算术能力测试系统
设计一个程序,用来实现帮助小学生进行算术运算练习,它具有以下功能:提供 10道加、
减、乘、除四种基本算术运算的题目,每道题中的操作数是随机产生的,且操作数不超过 2位
数的正整数;练习者根据显示的题目输入自己的答案,程序自动判断输入的答案是否正确并显
示出相应的信息。最后显示做对了几道题*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main( )
{
int iRight=0;
int i,iFuhao;
double dZheng,n1,n2;
for(i=0;i<10;i++)
{
srand(time(0));
iFuhao = rand()%4;
n1=rand()%100;
n2=rand()%100;
switch(iFuhao)
{
case 0:cout <<n1<<'+'<<n2<<'=';dZheng=n1+n2;break;
case 1:cout <<n1<<'-'<<n2<<'=';dZheng=n1-n2;break;
case 2:cout <<n1<<'*'<<n2<<'=';dZheng=n1*n2;break;
case 3:dZheng=n1/n2;
if(dZheng==(int)dZheng)
{cout <<n1<<'÷'<<n2<<'=';break;}
else
{
i--;
continue;
}
}
int dShu;
cin >> dShu;
if(dShu==dZheng)
{
cout<<"Right"<<endl;
iRight++;
}
else
{
cout<<"Error Right="<<dZheng<<endl;
}
}
cout << "共做对"<<iRight<<"道,"<<"得分"<<iRight*10<<"分。"<<endl;
return 0;
}
相关文章推荐
- 类和对象&重载
- MVC框架简谈与在Android中的应用
- codevs 1349 板猪的火车票
- 更新安装xcode7插件
- objective-C学习笔记(五)函数成员:初始化器和析构器
- android 之 启动画面的两种方法
- CentOS 下安装apt-get
- 软件项目管理第三周作业
- php 封装Memcache 队列缓存类
- MyBatis Mapper接口实现原理
- linux c++线程池开发demo
- POJ Mayor's posters (线段树成段更新 离散化666)
- Django--models一对多实例
- RunLoop基础
- Problem A: 删除区间内的元素(线性表)
- NFS – setfacl- quota 配置
- 挖坑——刷gty系列
- UESTC 1143
- Linux高级编程(2)
- UVA 10382(p79)----Watering Grass