# 小学生算数系统

#include <iostream>
#include <cstring>
#include<ctime>
#include<cstdlib>
using namespace std;
class Text
{
private:
string name;
int number;
int num;
int opera;
int score;
public:
Text(string n,int nu,int s)
{
name=n;
num=nu;
score=s;
}
void information();
void exam();
void display();
};
void Text::information()
{
cout<<endl;
cout<<"欢迎使用小学生测试系统"<<endl;
cout<<endl;
cout<<"     现在进行测验     "<<endl;
cout<<endl;
cout<<"  祝你考出一个好成绩  "<<endl;
cout<<endl;
cout<<"请输入你的姓名"<<endl;
cin>>name;
cout<<"请输入你的学号"<<endl;
cin>>number;
cout<<endl;
}
void Text::exam()
{
srand(time(0));
int i,result,n;
int figure;
int x,y;
for(i=1;i<=10;i++)
{
x=rand()%25;
y=rand()%25;
cout<<"第"<<i<<"题: ";
opera=rand()%2;
if(x<y)
{
n=x;
x=y;
y=n;
}
switch(opera)
{
case 0:
figure=x+y;
cout<<x<<"+"<<y<<"=";
break;
case 1:
figure=x-y;
cout<<x<<"-"<<y<<"=";
break;
}
cin>>result;
if(result==figure)
{
score=score+10;
if(i==10)
{
cout<<"考试结束，请查看成绩"<<endl;
break;
}
cout<<"答案正确，请继续进行测试！"<<endl;
}
else
{
cout<<"答案错误，请重新输入！"<<endl;
cin>>result;
if(result==figure)
{
score=score+7;
if(i==10)
{
cout<<"考试结束，请查看成绩"<<endl;
break;
}
cout<<"答案正确，请继续进行测试！"<<endl;
}
else
{
cout<<"答案错误，请重新输入！"<<endl;
cin>>result;
if(result==(x+y))
{
score=score+5;
if(i==10)
{
cout<<"考试结束，请查看成绩"<<endl;
break;
}
cout<<"答案正确，请重新输入！"<<endl;

}
else
{
if(i==10)
{
cout<<"考试结束，请查看成绩"<<endl;
break;
}
cout<<"答案错误，请查看正确答案！"<<endl;
cout<<figure<<endl;
score=score+0;
}
}
}
}
}

void Text::display()
{
if(score>90)
{
cout<<name<<"  你的分数为："<<score<<endl;
cout<<"Smart"<<endl;
}
else if(score>80&&score<=90)
{
cout<<name<<"  你的分数为："<<score<<endl;
cout<<"Good"<<endl;
}
else if(score>70&&score<=80)
{
cout<<name<<"  你的分数为："<<score<<endl;
cout<<"Ok"<<endl;
}
else if(score>60&&score<=70)
{
cout<<name<<"  你的分数为："<<score<<endl;
cout<<"Pass"<<endl;
}
else
{
cout<<name<<"  你的分数为："<<score<<endl;
cout<<"Try again"<<endl;
}
}
int main()
{
Text student("name",1,0);
student.information();
student.exam();
student.display();
return 0;
}

• 本文已收录于以下专栏：

举报原因： 您举报文章：小学生算数系统 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)