/*
*Copyright(c)2014,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:asd.cpp
*作 者:綦鹏
*完成日期:2016年3月28日
*版 本 号:v1.0
*
*问题描述:小学生计算题
*输入描述:你的结果
*程序输出:正确个数
*/
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,z,p=0;
int t,i;
srand(time(0));
for(i=0;i<10;i++)
{
x=rand()%100;
y=rand()%100;
t=rand()%4;
if(t==0) cout<<x<<"+"<<y<<"="<<endl;
if(t==1) cout<<x<<"-"<<y<<"="<<endl;
if(t==2) cout<<x<<"×"<<y<<"="<<endl;
if(t==3) cout<<x<<"÷"<<y<<"="<<endl;
if(x/y&&y==0)
continue;
cout<<"请输入答案:";
cin>>z;
if(t==0&&x+y==z)
{
cout<<"right";
p++;
}
else if(t==1&&x-y==z)
{
cout<<"right";
p++;
}
else if(t==2&&x*y==z)
{
cout<<"right";
p++;
}
else if(t==3&&x/y==z)
{
cout<<"right";
p++;
}
else
cout<<"wrong";
cout<<endl;
}
cout<<"你一共作对"<<p<<"道题"<<endl;
return 0;
}
*Copyright(c)2014,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:asd.cpp
*作 者:綦鹏
*完成日期:2016年3月28日
*版 本 号:v1.0
*
*问题描述:小学生计算题
*输入描述:你的结果
*程序输出:正确个数
*/
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,z,p=0;
int t,i;
srand(time(0));
for(i=0;i<10;i++)
{
x=rand()%100;
y=rand()%100;
t=rand()%4;
if(t==0) cout<<x<<"+"<<y<<"="<<endl;
if(t==1) cout<<x<<"-"<<y<<"="<<endl;
if(t==2) cout<<x<<"×"<<y<<"="<<endl;
if(t==3) cout<<x<<"÷"<<y<<"="<<endl;
if(x/y&&y==0)
continue;
cout<<"请输入答案:";
cin>>z;
if(t==0&&x+y==z)
{
cout<<"right";
p++;
}
else if(t==1&&x-y==z)
{
cout<<"right";
p++;
}
else if(t==2&&x*y==z)
{
cout<<"right";
p++;
}
else if(t==3&&x/y==z)
{
cout<<"right";
p++;
}
else
cout<<"wrong";
cout<<endl;
}
cout<<"你一共作对"<<p<<"道题"<<endl;
return 0;
}