//本程序能够随机产生100以内的整数的四则运算
#include "stdafx.h"
#include "stdio.h"
#include <stdlib.h>
#include <time.h>
void disply()
{
srand(time(NULL));
int i;
for(i=0;i<30;i++)
{
int a=rand()%100;
int b=rand()%100;
int c=rand()%4;
if(c==0){printf("%d+%d=\n",a,b);}
else if(c==1){printf("%d*%d=\n",a,b);}
else if(c==2&&a>b){printf("%d-%d=\n",a,b);}
else if(c==2&&a<=b){printf("%d-%d=\n",b,a);}
else if(c==3&&a>b){printf("%d/%d=\n",a,b);}
else if(c==3&&a<=b){printf("%d/%d=\n",b,a);}
}
}
void main()
{
disply();
}
//运算结果
时间: 2024-10-09 04:10:07