标签:
#include<stdlib.h> #include<stdio.h> #include<time.h> int main() { int a,i,n,o,x,y; float z; printf("请输入题目数:"); scanf("%d",&n); while(n--) { srand((unsigned)time(NULL)); x=rand()%100+1; y=rand()%100+1; o=rand()%4; switch(o) { case 0: printf("%d + %d = ",x,y); a=x+y; break; case 1: printf("%d - %d = ",x,y); a=x-y; break; case 2: printf("%d * %d = ",x,y); a=x*y; break; case 3: printf("%d / %d = ",x,y); a=x/y; break; } scanf("%f",&z); i=2; while(z!=a&&i--) { printf("答案错误!\n"); printf("正确答案是:%f!\n",a); break; } if(z==a) printf("答案正确!\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/cds94/p/4384556.html