四则运算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;

}

原文地址:https://www.cnblogs.com/gyy0/p/10246462.html