二柱子四则运算简单
2018-10-06 20:53 黄瑞波 阅读(172) 评论(0) 编辑 收藏 举报#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int x,y,z,t;
srand(time(NULL));
printf("二柱子的计算题:\n");
for(int i=0;i<30;i++)
{
x=rand()%100;
y=rand()%100;
z=rand()%4;
switch(z)
{
case 0:
printf("%d+%d=\n",x,y);
break;
case 1:
if(x<y)
{
t=x;
x=y;
y=t;
}
printf("%d-%d=\n",x,y);
break;
case 2:
printf("%d×%d=\n",x,y);
break;
case 3:
if(y!=0)
{
printf("%d÷%d=\n",x,y);
}
else
{
i=i-1;
}
break;
default:
printf("超出测试范围\n");
break;
}
}
printf("endl.\n");
return 0;
}