四则运算1

#include"iostream.h"

#include"stdlib.h"

#include"math.h"
#include"time.h"

int main(int argc, char* argv[])

{

int num1,num2;

int n;

srand( (unsigned)time( NULL ) );

for(int i=1;i<=30;i++)

{

num1=rand()%100;

num2=rand()%100;

n=rand()%4;

switch(n)

{

case 0:

cout<<i<<" "<<num1<<"+"<<num2<<"="<<endl;

break;

case 1:

if(num1>=num2)

{

cout<<i<<" "<<num1<<"-"<<num2<<"="<<endl;

break;

}

case 2:

cout<<i<<" "<<num1<<"x"<<num2<<"="<<endl;

break;

case 3:

cout<<i<<" "<<num1<<"/"<<num2<<"="<<endl;

break;

}

}

return 0;

}

 

posted @ 2019-01-09 19:38  高尉雅  阅读(75)  评论(0编辑  收藏  举报