/**
作者:程鹏远
题目:30道2年纪四则运算题目
要求:减法结果不为负数,除法能整除,除数不为0;
*/
#include <iostream.h>
#include <stdlib.h>
int main()
{
int a,b,c;
for(int i=0;i<30;i++)
{
cout<<"第"<<i+1<<"题: ";
a=rand()%100;//x+rand()%(y-x+1)随机生成【x,y】内的整数
b=rand()%100;
c=rand()%4;
switch (c)
{
case 1:
cout<<a<<"+"<<b<<"="<<endl;
break;
case 2:
if(a>b){cout<<a<<"-"<<b<<"="<<endl;}
else{cout<<b<<"-"<<a<<"="<<endl;}
break;
case 3:
cout<<a<<"*"<<b<<"="<<endl;
break;
case 0:
int j=0;
while((j<100000)&&(a!=0)&&(b!=0)&&(a%b==0)){cout<<a<<"/"<<b<<"="<<endl;i++;j++;}
if((a!=0)&&(b!=0)&&(a%b==0)){cout<<a<<"/"<<b<<"="<<endl;i++;}
else{
int j=0;
while(j<100000)
{
a=rand()%1000;//x+rand()%(y-x+1)随机生成【x,y】内的整数
b=rand()%100;
if((a!=0)&&(b!=0)&&(a%b==0)){cout<<a<<"/"<<b<<"="<<endl;i++;j=100000;j++;}
else{j++;}
}
}
break;
}
}
return 0;
}