• 四则运算


    #include <stdlib.h>
    #include<stdio.h>
    #include <iostream.h>
    #include <conio.h>
    #include <time.h>
    int main()

      int a = 0;
      int b = 0;
      int mode = 0;
      int c=0;
      int result = 0;
      int score = 0;
      int i = 0;
      int n;
      int x;
      for(i=0;i<30;i++)
      {
         a = rand() % 100;
         b = rand() % 100;  
         mode = rand() % 4;      
         printf("%d", a);   
         switch(mode)        
      {          
             case 0:
        printf("+ ");               
                 result= a + b;         
              break;          
             case 1:
        printf("- ");               
                 result= a - b;               
              break;
       case 2:
        printf("x ");               
                 result= a * b;              
              break;          
             case 3:               
                 printf("÷ ");               
                 result= a / b;
              break;          
              default:              
                 printf("somethingis wrong!\n");               
              break;         
      }
         printf("%d = ", b);
         if(result==a/b&&a!=4&&b!=2)
      {
       scanf("%d/%d",&n,&x);
          getchar();
          if(n/x==a/b)
       {
        score+= 10;            
                 printf("Right\n\n");
       }
             else       
       { 
                 printf("Wrong\n\n");
                 getchar();       
       }
      }
        else
     {
      scanf("%d",&c);
            getchar();
            if(c==result)         
      {
       score+= 10;            
                printf("Right\n\n"); 
      }
      else       
      { 
       printf("Wrong\n\n");
                getchar();
      }
     }
     }
       printf("Yourscore is: %d\n\n\n", score);   
       return 1;
    }

  • 相关阅读:
    POJ1845 数论 二分快速取余
    CentOS6.5下安装wine
    Centos 6.5中安装后不能打开emacs的问题
    vim编辑器的设置文件
    centos无线网卡设置
    FreeBSD简单配置SSH并用root远程登陆方法
    在CentOS/RHEL 6.5上安装Chromium 谷歌浏览器
    Centos中安装Sublime编辑器
    强连通分量!
    强连通分量
  • 原文地址:https://www.cnblogs.com/hcwys/p/7608837.html
Copyright © 2020-2023  润新知