#include <stdio.h>
#include <stdlib.h>
main(){
{int i; 
int s=0;
int f;
int count=0;
char c;
printf("请计算以下10题,每题10分:\n");

for(i=0;i<10;i++)
{
 int a=rand()%100;
 int b=rand()%100;
 int  d=rand()%4 ;

 switch(d){
 case 0:
  c='+';
  s=a+b;
  printf("%d %c %d=",a,c,b);
   scanf("%d",&f);
  if(f==s)
  {
   printf("回答正确!\n");
   count++;
  }
   else
   printf("回答错误!\n");
   getchar();
  break;
 case 1:
  c='-4';
  s=b-a;
  printf("%d %c %d=",b,c,a);
   scanf("%d",&f);
  if(f==s)
  {
   printf("回答正确!\n");
        count++;
  }
  else
  {
   printf("回答错误!\n");
  } getchar();
  break;
  case 2:
  c='/';
  s=a/b;
  if(a%b!=0){
   printf("该题有余数。答案只要整数部分!");
  }
  printf("%d %c %d=",a,c,b);
   scanf("%d",&f);
  if(f==s)
  { printf("回答正确!\n");
  count++;
  }
  else
   printf("回答错误!\n");
  break;
  case 3:
  c='*';
  s=a*b;
  printf("%d %c %d=",a,c,b);
          scanf("%d",&f);
  if(f==s)
  { printf("回答正确!\n");
         count++;
  }
  else
   printf("回答错误!\n");
  break;
 }
}

printf("恭喜你答对了%d题",count);
}
}

答案只能是整数。没有判断是否负数功能。

相关文章:

  • 2022-03-01
  • 2022-02-18
  • 2021-12-27
  • 2021-11-20
  • 2021-07-14
  • 2021-07-30
  • 2021-11-15
  • 2021-07-24
猜你喜欢
  • 2021-07-21
  • 2022-01-04
  • 2021-07-20
  • 2022-01-12
  • 2021-07-07
  • 2021-07-24
  • 2021-05-21
相关资源
相似解决方案