#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int random_int(int low, int high);
char random_opt(char opts[], int optLen);
int main()
{
char opts[4] = "+-*/";
srand( time(NULL) );
int first = random_int(1, 100);
int last = random_int(1, 100);
char opt = random_opt(opts, 4);
printf("%d %c %d = \n", first, opt, last );
return 0;
}
int random_int(int low, int high)
{
return low + rand() % ( high - low );
}
char random_opt(char opts[], int optLen)
{
return opts[ rand() % optLen ];
}
温馨提示:内容为网友见解,仅供参考