注册 登录
编程论坛 C++教室

编程,急需解决,谢谢

chencangolds 发布于 2012-02-22 19:37, 371 次点击
1. 编程序,循环进行如下的处理过程:由计算机生成简单的四则运算题;用户给出答案;计算机判断对错。直到用户回答说不再继续做了时结束程序。
提示:可让用户选择指定出加、减、乘、除哪一种运算题,以及出一位数还是两位数的运算题;而后通过使用“rand()%10”或“rand()%100”来获得一个0到9的一位整数随机值或得到0到99的两位整数随机值来为用户出题。还可进一步对用户所做算术题的对错次数进行记录,结束程序时给出一个某种形式的成绩。


#include<iostream>
using namespace std;
int main()
{int m,n,t,i;
cout<<”请选择类型+-*/”
cin>>t;
*=t;-=t;+=t;/=t;
switch(i!=0){              /*用switch来让用户选择加,减,乘,除*/
case( “*”):
int t,I,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)     //选择一位数或多位数//
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i*i++=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

Case(”+”):
int t,i,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i+i++=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

case(”_”):
int t,i,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i++_i=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

case(”/”):
int t,I,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i++/i=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

cout<<n++<<’/t’<<m++<<endl;
return 0
}
这是我编写的思路,请大家看看,或者帮忙重新写一下
4 回复
#2
YHL88okok2012-02-22 23:30
bbb
#3
CooperOne2012-02-29 20:48
程序代码:
#include<iostream>
using namespace std;
int main()
{int m,n,t,i;
cout<<”请选择类型+-*/”
cin>>t;
*=t;-=t;+=t;/=t;
switch(i!=0){              /*用switch来让用户选择加,减,乘,除*/
case( “*”):
int t,I,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)     //选择一位数或多位数//
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i*i++=t;
cin>>n>>endle;
if n==t cout<<”right”
else {cout<<”wrong”;  m++;}

Case(”+”):
int t,i,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i+i++=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

case(”_”):
int t,i,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i++_i=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

case(”/”):
int t,I,n,m;
cout<<”请选择位数:1或2或随机t”
cin>>m;
m=1; m=2;  m=t;
switch(m!=0)
case(1):  if (i>=0&&i<=9 )  for(i=0; i<=9;i++)
case(2):  if(i>=10) for(i=10; i>=10;i++)
case(t):  i=rand(t)%10
i++/i=t;
cin>>n>>endle;
if n==t cout<<”right”
else cout<<”wrong”  m++

cout<<n++<<’/t’<<m++<<endl;
return 0
}
加减乘除不是变量,更加不是int型
引号是英文状态下的输入,就算是中文输入法下的英文输入,也要把英文标点弄对

要改起来不是小的修改
#4
CooperOne2012-02-29 20:49
无视代码吧....本来想加颜色着重的...发现没用
#5
CooperOne2012-02-29 21:03
好吧其实也没有那么吓人,把加减乘除作为字符string或者char神马的
然后case判断
1