二柱子四则运算程序

#include <stdio.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; //产生随机符号0到3分别代表四则运算
  printf("%d", a);
  switch (j)
  {
  case 0:
   printf("+");
   break;
  case 1:
   printf("-");
   break;
  case 2:
   printf("*");
   break;
  case 3:
   printf("/");
   break;
  }
  printf("%d", b);
  printf(" = \n");
  i++;
 }
 getchar();
 getchar();
 return 0;
}

此程序只支持整数四则运算出题。

猜你喜欢

转载自www.cnblogs.com/DreamerT/p/9756258.html
今日推荐