急!求大神帮忙做个C++期末作业

啊,今天就要交了。哪位大神帮帮忙吧《我猜!我猜!我猜猜猜!》游戏要求:用户希望开发一个新游戏。游戏面向小学1~2年级学生,随机选择两个整数和加减法形成算式要求学生解答。要... 啊,今天就要交了。哪位大神帮帮忙吧
《我猜!我猜!我猜猜猜!》游戏要求:用户希望开发一个新游戏。游戏面向小学1~2年级学生,随机选择两个整数和加减法形成算式要求学生解答。
要求:
(1)只出10道题,每题10分,程序结束时显示游戏参与者得分(和用了多少时间);
(2)确保算式没有超出1~2年级的水平,只允许进行随机性的50以内数值做随机性的加法或减法(或乘法,则随机数值范围在1~9),不允许两数之和或之差超出0~50的范围,负数更是不允许的;
(3)每道题游戏参与者有三次机会输入答案,当游戏参与者输入错误答案时,提醒游戏参与者重新输入,如果三次机会结束则输出正确答案;
(4)对于每道题,游戏参与者第一次输入正确答案得10分,第二次输入正确答案得7分,第三次输入正确答案得5分,否则不得分;
(5)当游戏参与者输入了正确得数后,随机显示评价结果,例如“Right!”、“Correct!”、“You got it!”、“That's the answer!”、“Bingo!”, “Gaoging!”等,若答案错误,则按照相应的回答机会随机输出“No, the answer is …”、“Error! Try again. please!” 、“Wrong! once again. please!” 、“No! a second time. please!” 、“Mistaken! a last time. please!” 、“No! once more. please!”等错误信息,若第3次还是回答错误,则除了输出随机错误信息,并输出正确答案信息。
感激不尽啊,可以发到我邮箱zhougan159@qq.com。

才发现只有40财富币了,会不会太少。如果大神帮了忙,肯定不会只这一点的啦
展开
 我来答
382186400
2013-06-09
知道答主
回答量:29
采纳率:0%
帮助的人:22.6万
展开全部
#include <iostream>
#include <iomanip>
#include "time.h"
#include "stdio.h"
#include "stdlib.h"
#include <string.h>
using namespace std;
char ff[20];
int input()
{

g:
cin>>ff;
if(strlen(ff)>2||(ff[0]>='a'&&ff[0]<='z')||(ff[0]>='A'&&ff[0]<='Z')||(ff[1]>='a'&&ff[1]<='z')||(ff[1]>='A'&&ff[1]<='Z'))
{
cout<< "the result input error!! input number! " <<endl;
goto g;
}
return 0;
}
int main(void)
{
srand(time(NULL));
int time0=time(NULL);
int time1=0;
int mark,a,b,result,i,Operator,j,t;
int result1;
mark=a=b=result=0;
string op;
string right[6] ={
"Right!",
"Correct!",
"That's the answer!",
"Bingo!",
"Gaoging!",
};
string wrong[6]={
"No, the answer is wrong",
"Error! Try again. please!",
"Wrong! once again. please!",
"No! a second time. please!",
"Mistaken! a last time. please!",
"No! once more. please!",
};

cout<<"Begin answer ten questions"<<endl;
for(j=0;j<10;j++)
{
Operator = rand()%3 ;
switch(Operator)
{
case 0 :
l: a= rand()%50;
b= rand()%50;
result=a+b;
if(result>50)
goto l;
else
break;
case 1 :
k: a= rand()%50;
b= rand()%50;
result=a-b;
if(result<0||result>50)
goto k;
else
break;
case 2:
f: a= rand()%9;
b= rand()%9;
result=a*b;
if(result>50)
goto f;
else
break;
}

if(Operator==0)
op="+";
if(Operator==1)
op="-";
if(Operator==2)
op="*";
cout<<a<<op<<b<<"=";
input();
cout<<endl;
for(i=0,t=0;i<3;i++)
{
if(strlen(ff)==2)
result1=(ff[0]-'0')*10+ff[1]-'0';
else
result1=ff[0]-'0';
if(result1==result)
{
cout<<right[rand()%6]<<endl;
if(i==0)
mark+=10;
if(i==1)
mark+=7;
if(i==2)
mark+=5;
break;
}
else if(result1!=result)
{
t++;
if(t==3)
break;
cout<<wrong[rand()%6]<<endl;
cout<<a<<op<<b<<"=";
input();

cout<<endl;

}
}

if(t==3)
{

cout<<"THE ANSWER IS:"<<endl;
cout<<a<<op<<b<<"="<<result<<endl;
cout<<endl;
}
else
cout<<endl;

}
time1=time(NULL);
cout<<"YOU MARKS:"<<mark<<endl;
cout<<"YOU USED TIMES:"<<time1-time0<<"second"<<endl;
system("pause");
return 0;
}
百度网友594d205f21
2013-06-09 · TA获得超过271个赞
知道小有建树答主
回答量:769
采纳率:0%
帮助的人:333万
展开全部
问题解决没有?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式