四则运算<C++>

代码:

#include<iostream>
#define N 30
using namespace std;

void main()
{
    cout<<"****************************************"<<endl;
    cout<<endl;
    cout<<"               四则运算                 "<<endl;
    cout<<endl;
    cout<<"****************************************"<<endl;

    double a[N],b[N];
    int i,j;
    
    for(i=0;i<N;i++)
    {
        a[i]=rand()%99;b[i]=rand()%99;
        j=rand()%5;

        if(j==1)
        {
            cout<<a[i]<<"+"<<b[i]<<"="<<endl;
        }
        if(j==2)
        {
            cout<<a[i]<<"-"<<b[i]<<"="<<endl;
        }
        if(j==3)
        {
            cout<<a[i]<<"*"<<b[i]<<"="<<endl;
        }
        if(j==4)
        {
            cout<<a[i]<<"/"<<b[i]<<"="<<endl;
        }
    }
    
}

 

课堂未完成原因:没有写随机的加减乘除;

posted @ 2015-03-06 13:12  小凤凰  Views(215)  Comments(0Edit  收藏  举报