#include
#include "stdlib.h"
#include "time.h"
/* main:some simple output */
void main()
{
int num1,num2;
srand((unsigned)time(NULL));
//产生两位数随尺早机数陵段雀
do
{
num1 = rand()%90+10;
num2 = rand()%90+10;
}while (num1
if (num1>num2)
{
printf("大于");
}
else{
printf("小于");
}
}
10 + rand() % 90
产生后,比较大小滚键,大的作大仔巧被减数
参考如下:戚桐
#include
#include
#include
void swap(int* pNum1, int * pNum2)
{
int temp;
temp = *pNum2;
*pNum2 = *pNum1;
*pNum1 = temp;
}
void main()
{
srand(time(0));
for(int i = 0; i < 100 ;++i)
{
char op[2] = {'*','-'};
int num1 = 10 + rand() % 90;
int num2 = 10 + rand() % 90;
int opIndex = rand() % 2;
if(opIndex == 1)
{
if(num1 < num2)
swap(&num1,&num2);
}
printf("%d %c %d \n",num1,op[opIndex],num2);
}
}
%100 即 mod 100