zoukankan      html  css  js  c++  java
  • 随机四则运算(小数)阿西巴分数怎么做?!

    #include<stdio.h>
    #include<math.h>
    #include<windows.h>
    int right=0;
    int wrong=0;
    void add()
    {
     float a,b,c;
     a=rand()%100;
     b=rand()%100;
     printf("请回答: %d + %d = ",a,b);
     scanf("%d",&c);
     if(a+b==c)
     {
      printf("回答正确! ");
      right++;
     }
     else
     {
      printf("回答错误! ");
      wrong++;
     }
    }
    void minu()
    {
     float a,b,c;
     a=rand()%100;
     b=rand()%100;
     printf("请回答: %d - %d = ",a,b);
     scanf("%d",&c);
     if(a-b==c)
     {
      printf("回答正确! ");
      right++;
     }
     else
     {
      printf("回答错误! ");
      wrong++;
     }
    }
    void mul()
    {
     float a,b,c;
     a=rand()%100;
     b=rand()%100;
     printf("请回答: %d * %d = ",a,b);
     scanf("%d",&c);
     if(a*b==c)
     {
      printf("回答正确! ");
      right++;
     }
     else
     {
      printf("回答错误! ");
      wrong++;
     }
    }
    void di()
    {
     float a,b,c;
     a=rand()%100;
     b=rand()%100;
     printf("请回答: %d / %d = ",a,b);
     scanf("%d",&c);
     if(a/b==c)
     {
      printf("回答正确! ");
      right++;
     }
     else
     {
      printf("回答错误! ");
      wrong++;
     }
    }
    void main()
    {
     int choise;
     int con=0;
     printf(" 欢迎进入小学简易四则运算 ");
     printf("请选择: ");
     printf("  开始运算(请输入1) ");
     printf("  退出运算(请输入2) ");
     scanf("%d",&con);
     while(1)
     {
      
      if(con==1)
      switch(choise=rand()%4)
      {
      case 0:
       add();
       break;
      case 1:
       minu();
       break;
      case 2:
       mul();
       break;
      case 3:
       di();
       break;
      default:
       return -1;
      }
      else
     if(con==2)
     break;
     else
      printf("抱歉!,你输入的指令有误!请重新输入! ");
      printf(" 继续运算?(请输入1) ");
      printf(" 退出运算?(请输入2) ");
      scanf("%d",&con);
      if(con==1)
       con=1;
      else if(con==2)
       break;
      else
       printf("抱歉!,你输入的指令有误!请重新输入! ");
     }
     printf("您总共完成了 %d 道题 正确 %d 道 错误 %d 道 ",right+wrong,right,wrong);
    }
  • 相关阅读:
    weblogic weak_password 复现
    redis 4-unacc 复现
    Django debug page XSS漏洞(CVE-2017-12794)复现
    (CVE-2016-4437)Apache Shiro <=1.2.4 反序列化漏洞复现
    Apache SSI 远程命令执行漏洞复现
    Apache HTTPD 未知后缀解析漏洞复现
    s2-005复现
    05 跨站请求伪造漏洞CSRF
    安全大面
    JAVA基础学习day03--流程控制语句
  • 原文地址:https://www.cnblogs.com/yangyang0717/p/5471279.html
Copyright © 2011-2022 走看看