zoukankan      html  css  js  c++  java
  • 四则运算升级

    源程序:

    #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! ");              
              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 ");
       }
             else      
       {
                 printf("Wrong ");
                 getchar();      
       }
      }
        else
     {
      scanf("%d",&c);
            getchar();
            if(c==result)        
      {
       score+= 10;           
                printf("Right ");
      }
      else      
      {
       printf("Wrong ");
                getchar();
      }
     }
     }
       printf("Yourscore is: %d ", score);  
       return 1;
    }

    输很长字母,还是会出错,不知道怎么解决!

  • 相关阅读:
    《R语言入门与实践》第七章:程序
    《R语言入门与实践》第六章:R 的环境系统
    《R语言入门与实践》第五章:对象改值
    《R语言入门与实践》第四章:R 的记号体系
    pandas包的应用
    numpy包的应用
    redis
    面试题
    qqqqqqq
    qqqqqqqqqqqqq
  • 原文地址:https://www.cnblogs.com/lixin20/p/4383534.html
Copyright © 2011-2022 走看看