第四周项目3①-小学生算术能力测试系统
2016-03-30 20:54
344 查看
/*
*Copyright (c) 2015,烟台大学计算机学院
*All rights reserved.
*文件名称:text.cpp
*作者:陈腾
*完成日期:2015年3月24日
*版本号:v1.0
*
*问题描述:设计小学生的加减乘除的十道题随机产生
*输入描述:输入十个整数
*程序输出:输出结果是否正确及正确个数
*/
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int i,right=0,sum,amount=1,m;
int x,y;
for(i=0;i<10;i++)
{
x=rand()%100;
y=rand()%100+1;
if(x<y)
{
m=x;
x=y;
y=m;
}
cout<<"第"<<amount<<"题:";
srand(time(0));
switch(x%4)
{
case 0:
{
cout<<x<<"+"<<y<<"=";
cin>>sum;
if(sum==(x+y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
case 1:
{
co
4000
ut<<x<<"-"<<y<<"=";
cin>>sum;
if(sum==(x-y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
case 2:
{
cout<<x<<"*"<<y<<"=";
cin>>sum;
if(sum==(x*y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
case 3:
{
x=(y)*(rand()%10);
cout<<x<<"/"<<y<<"=";
cin>>sum;
if(sum==(x/y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
}
amount++;
}
cout<<"做对了:"<<right<<"道题,得分为:"<<right*10;
return 0;
}
/*
*Copyright (c) 2015,烟台大学计算机学院
*All rights reserved.
*文件名称:text.cpp
*作者:陈腾
*完成日期:2015年3月24日
*版本号:v1.0
*
*问题描述:设计小学生的加减乘除的十道题随机产生
*输入描述:输入十个整数
*程序输出:输出结果是否正确及正确个数
*/
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int i,right=0,sum,amount=1,m;
int x,y;
for(i=0;i<10;i++)
{
x=rand()%100;
y=rand()%100+1;
if(x<y)
{
m=x;
x=y;
y=m;
}
cout<<"第"<<amount<<"题:";
srand(time(0));
switch(x%4)
{
case 0:
{
cout<<x<<"+"<<y<<"=";
cin>>sum;
if(sum==(x+y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
case 1:
{
co
4000
ut<<x<<"-"<<y<<"=";
cin>>sum;
if(sum==(x-y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
case 2:
{
cout<<x<<"*"<<y<<"=";
cin>>sum;
if(sum==(x*y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
case 3:
{
x=(y)*(rand()%10);
cout<<x<<"/"<<y<<"=";
cin>>sum;
if(sum==(x/y))
{
cout<<"right"<<endl;
right++;
}
else cout<<"wrong"<<endl;
break;
}
}
amount++;
}
cout<<"做对了:"<<right<<"道题,得分为:"<<right*10;
return 0;
}
相关文章推荐
- 51nod1079中国剩余定理
- 山东省第一届ACM大学生程序设计竞赛 Phone Number 字典树
- zoj3228(AC自动机进阶)
- DICLERGE:飞行轨迹聚类的“分割-聚类-融合”框架
- Spring 3.x中三种Bean配置方式比较
- IT行业导览-第6章-转行
- Spring--AOP的实现
- 今天居然在谎称支付宝又返现2元
- 【Eclipse】 Eclipse 中JPEGEncodeParam 错误波浪线问题
- GCD中的dispatch_group函数的详解
- Poj 3181 Dollar Dayz【整数划分+大数】
- Oracle常用命令大全
- 今天申请了博客。
- 百度地图为啥定位不了
- HDU 2153 仙人球的残影(类蛇形填数)
- STM32 串口采用DMA方式收发
- C语言经典小程序(热门题型)
- hprose rpc使用实例(同时有Java和Delphi客户端的例子)
- 84. Largest Rectangle in Histogram *HARD* -- 柱状图求最大面积 85. Maximal Rectangle *HARD* -- 求01矩阵中的最大矩形
- windows 查看端口被占用