搜索
查看: 718|回复: 5
打印 上一主题 下一主题

这。。。。。。

[复制链接]
楼主
发表于 2014-2-27 22:58:12 | 显示全部楼层
  1. //是不是少了个头文件,,试试我给你修改了的代码~~
  2. //这是C++语言吧~
  3. #include<iostream>
  4. #include<cstdlib>
  5. #include<ctime>
  6. using namespace std;
  7. int score=0;
  8. void jisuan(int a,int b)
  9. {
  10. int count=1,sum,t,n;

  11. if((a+b)%2==0)
  12. { n=3;
  13.   sum=a+b;
  14.   cout<<"请计算:"<<a<<"+"<<b<<"=";
  15.   while(n--)
  16.   {
  17.   cin>>t;
  18.   if(t==sum)
  19.    {if(count==1)
  20.    score+=10;
  21.    if(count==2)
  22.    score+=7;
  23.    if(count==3)
  24.    score+=5;
  25.    return ;
  26.    }
  27.   else
  28.   {  if(count!=3)
  29.    cout<<"您的答案好像不对哦,请重新输入:";
  30.    else
  31.     { cout<<"您已经错了三次.."<<endl;
  32.   cout<<"正确答案是:"<<sum<<endl;
  33.     return ;
  34.     }
  35.    count++;
  36.   }
  37.   }
  38. }
  39. else
  40. { n=3;
  41.   if(a<b)
  42.   { t=a;
  43.    a=b;
  44.    b=t;
  45.   }
  46.   sum=a-b;
  47.   cout<<"请计算:"<<a<<"-"<<b<<"=";
  48.   while(n--)
  49.   { cin>>t;
  50.   if(t==sum)
  51.    {if(count==1)
  52.    score+=10;
  53.    if(count==2)
  54.    score+=7;
  55.    if(count==3)
  56.    score+=5;
  57.    return ;
  58.    }
  59.   else
  60.   { if(count!=3)
  61.    cout<<"您的答案好像不对哦,请重新输入:";
  62.    else
  63.     { cout<<"您已经错了三次.."<<endl;
  64. cout<<"正确答案是:"<<sum<<endl;
  65.     return ;
  66.     }
  67.     count++;
  68.   }
  69.   
  70.   }
  71. }

  72. }
  73. int main()
  74. { int n=10;
  75. int a,b,i,j,sum;
  76. while(n--)
  77. {
  78.   srand(unsigned(time(0)));
  79.   a=rand()%50;
  80.   srand(unsigned(time(0)));
  81.   b=rand()%49;
  82.   while(1)
  83.   {
  84.   if(a+b<50)
  85.    break;
  86.   if(a>0)
  87.   a--;
  88.   if(b>0)
  89.   b--;
  90.   }
  91.   jisuan(a,b);
  92.   
  93. }
  94. cout<<"您的成绩为:"<<score<<endl;
  95. if(score>=90)
  96.   cout<<"******************SMART******************";
  97. else if(score>=80&&score<90)
  98.   cout<<"******************GOOD******************";
  99. else if(score>=70&&score<80)
  100.   cout<<"*******************OK*******************";
  101. else if(score>=60&&score<70)
  102.   cout<<"******************PASS******************";
  103. else if(score>=60&&score<70)
  104.   cout<<"************TRY AGAIN**************";
  105. return 0;
  106. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表