您的位置:首页 > 其它

小学算数

2016-03-22 19:16 363 查看
#include <iostream>

#include<ctime>

#include<cstdlib>

using namespace std;

int main()

{

 srand(time(0));

    int i,right=0,result,amount=1,m,n;

    int x,y;

    for(i=1;i<=10;i++)

    {

       

        x=rand()%100;

        y=rand()%100+1;

        cout<<"第"<<amount<<"题: ";

  

        m=x%4;

        if(x<y)

        {

            n=x;

            x=y;

            y=n;

        }

        if(m==0)

        {

           cout<<x<<"+"<<y<<"=";

           cin>>result;

           if(result==(x+y))

     {

                cout<<"right"<<endl;

    right++;

     }

            else

               cout<<"wrong"<<endl;

        }

        else if(m==1)

        {

           cout<<x<<"-"<<y<<"=";

           cin>>result;

           if(result==(x-y))

     {

                cout<<"right"<<endl;

    right++;

     }

            else

                cout<<"wrong"<<endl;

        }

        else if(m==2)

        {

           cout<<x<<"*"<<y<<"=";

           cin>>result;

           if(result==(x*y))

     {

                cout<<"right"<<endl;

    right++;

     }

            else

                cout<<"wrong"<<endl;

        }

        else if(m==3)

        {

           int yushu;

           cout<<x<<"/"<<y<<"=";

           cin>>result>> yushu;

           if(result==(x/y)&&yushu==(x%y))

     {

                cout<<"right"<<endl;

    right++;

     }

            else

               cout<<"wrong"<<endl;

        }

        amount++;

    }

    cout<<"正确"<<right<<"道题,最终得分为"<<10*right;

    return 0;

}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: