任务,出30道100以内的四则运算,不能有重复
代码
#include <stdlib.h> #include <stdio.h> #include <time.h> main( ) { int a=0; int b=0; int i,c; srand((unsigned)time(NULL)); for (i=0;i<30;i++) { a=rand()%100; b=rand()%100; c=rand()%4; printf("%d",a); switch(c) { case 0: printf("+%d= ",b); break; case 1: printf("-%d= ",b); break; case 2: printf("*%d= ",b); break; case 3: printf("/%d= ",b); break; default: printf("错误 "); break; } } return 0;
}
运行结果