小学算数
2016-03-22 19:16
363 查看
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(0));
int i,right=0,result,amount=1,m,n;
int x,y;
for(i=1;i<=10;i++)
{
x=rand()%100;
y=rand()%100+1;
cout<<"第"<<amount<<"题: ";
m=x%4;
if(x<y)
{
n=x;
x=y;
y=n;
}
if(m==0)
{
cout<<x<<"+"<<y<<"=";
cin>>result;
if(result==(x+y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
else if(m==1)
{
cout<<x<<"-"<<y<<"=";
cin>>result;
if(result==(x-y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
else if(m==2)
{
cout<<x<<"*"<<y<<"=";
cin>>result;
if(result==(x*y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
else if(m==3)
{
int yushu;
cout<<x<<"/"<<y<<"=";
cin>>result>> yushu;
if(result==(x/y)&&yushu==(x%y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
amount++;
}
cout<<"正确"<<right<<"道题,最终得分为"<<10*right;
return 0;
}
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(0));
int i,right=0,result,amount=1,m,n;
int x,y;
for(i=1;i<=10;i++)
{
x=rand()%100;
y=rand()%100+1;
cout<<"第"<<amount<<"题: ";
m=x%4;
if(x<y)
{
n=x;
x=y;
y=n;
}
if(m==0)
{
cout<<x<<"+"<<y<<"=";
cin>>result;
if(result==(x+y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
else if(m==1)
{
cout<<x<<"-"<<y<<"=";
cin>>result;
if(result==(x-y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
else if(m==2)
{
cout<<x<<"*"<<y<<"=";
cin>>result;
if(result==(x*y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
else if(m==3)
{
int yushu;
cout<<x<<"/"<<y<<"=";
cin>>result>> yushu;
if(result==(x/y)&&yushu==(x%y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
}
amount++;
}
cout<<"正确"<<right<<"道题,最终得分为"<<10*right;
return 0;
}
相关文章推荐
- 博客网址
- 给eclipse安装color-theme插件
- Mysql To Charts(一)--Express 应用生成器
- Android studio 开发快捷键使用(新手)
- iOS 极光推送快速最新集成(2.1.0)
- 计算税率
- 【Java】Java中的JDBC
- android的五种存储方式SharedPreferences、文件存储、SQLite数据库、ContentProvider、网络存储
- RTCP协议介绍
- C语言学习第一天
- Arpg 之旅
- 怎样给filter加入自己定义接口及调用
- Java 虚拟机面试题全面解析(干货)
- Web 开发中很实用的10个效果【附源码下载】
- iOS开发之UITextView,设置textView的行间距及placeholder
- 2010年中兴面试题
- 重载函数调用操作符
- hdu 5317 RGCDQ (dp+筛法)
- WorkBench插入中文数据??问题
- 计算一年有多少天