Home  >  Article  >  Backend Development  >  201306114357-Experiment 1, 201306114357-Experiment_PHP Tutorial

201306114357-Experiment 1, 201306114357-Experiment_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 09:58:40924browse

201306114357-实验1,201306114357-实验

#include
#include
#include
main()
{
 int a,b,c;
 float resultTrue=0,n;
 char op;
 srand(time(NULL));
 do
 {
  a=rand() 1;
  b=rand() 1;
  c=rand()%4 1;
  switch(c%4)
  {
  case 0:
   {
    op=' ';
    break;
   }
  case 1:
   {
    op='-';
    break;
   }
  case 2:
   {
    op='*';
    break;
   }
  case 3:
   {
    op='/';
    break;
   }
  }
  printf("%d%c%d=n",a,op,b);
  switch(op)
  {
   case ' ':
   {
    resultTrue=a b;
    break;
   }
   case '-':
    {
     resultTrue=a-b;
     break;
    }
   case '*':
    {
     resultTrue=a*b;
     break;
    }
   case '/':
    {
     resultTrue=a/b;
     break;
    }
  }
  printf("请输入正确答案(1000为结束):");
  scanf("%f",&n);
  if(n!=0)
  {
  if(resultTrue!=n)
  {
   printf("答案错误,答案为%dn",resultTrue);
  }
  if(resultTrue==n)
  {
   printf("答案正确n");
  }
  }
  if(n==10000)
  {
   return;
  }
 }while(1);
}

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/977083.htmlTechArticle201306114357-实验1,201306114357-实验 #includestdio.h #include stdlib.h #include time.h main() { int a,b,c; float resultTrue=0,n; char op; srand(time(NULL)); do { a=rand() ...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn