四则运算

#include <iostream.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
int i = 0;
srand((unsigned)time(NULL));
while(i<30)
{

int a = rand()%100;
int b = rand()%100;
int j;
j = rand()%4;
cout<<a;
switch(j)
{
case 0:
cout<<"+";
break;
case 1:
cout<<"-";
break;
case 2:
cout<<"*";
break;
case 3:
cout<<"/";
break;
}
cout<<b<<"= ";
i++;
if(i%5==0)
cout<<endl;
}

return 0;
}

 

posted @ 2015-03-07 17:40  小崔007  阅读(128)  评论(0编辑  收藏  举报