#include <stdio.h>
#include <time.h>
static int a,b,sign,result
int fun(){
a = rand()%100+1
b = rand()%100+1
sign = rand()%4
switch(sign){
case 0:
result = a+b
printf("%d+%d=?\n",a,b)
break
case 1:
result = a-b
printf("%d-%d=?\n",a,b)
break
case 2:
result = a*b
printf("%d*%d=?\n",a,b)
break
case 3:
result = a/b
printf("%d/%d=?\n",a,b)
break
}
return result
}
void main(){
int i,flag=0,answer
for(i = 0i<消拍10i++){
fun()
printf("enter the answer\n")
scanf("%d",&answer)
if(answer == result)
flag++
}
printf("Your Answer is%d",10*flag)
}
大致销滚的意思就是这亏桥余样了 而且能跑了
具体的小细节你可以改改
楼主好运
#include<渣侍stdio.h>#include<stdlib.h>
main()
{
float a,b,rechar c printf("input(like 12+15 or 12*15):\n"氏橘) scanf("%f",&a)
do{
scanf("%c",&c)}while(c == ' ')scanf("%f",&b) switch(c)
{
case '+': re = a+bbreakcase '-': re = a-bbreakcase '*': re = a*bcase '歼梁团/': re = a/bdefault: break
}
printf("output the result:%.1f\n",re)system("pause")
}
输入示例: 2+3(or 2*3 or 2-3 or 2/3)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)