zoukankan      html  css  js  c++  java
  • 二年级的30道四则运算题

    想法思路:(1)在1-100之内产生两个随机数,并且随机的进行四则运算;

                  (2)循环进行30次,产生30道题;

                  (3)二年级时,没有学到分数和负数,减数要小于或等于被减数。

    源程序代码:

    #include "stdafx.h"

    #include"iostream.h"

    #include"stdlib.h"

    #include"math.h"
    #include"time.h"

    int main(int argc, char* argv[])

    {    

            int a,b;    

            int m;   

            srand( (unsigned)time( NULL ) );

            for(int i=1;i<=30;i++)  

           {   

                    a=rand()%100;     

                    b=rand()%100;  

                    m=rand()%4;   

                    switch(m)   

                   {    

                          case 0:     

                               cout<<i<<" "<<a<<"+"<<b<<"="<<endl;    

                               break;    

                          case 1:    

                                if(a>=b)    

                                {     

                                      cout<<i<<" "<<a<<"-"<<b<<"="<<endl;     

                                      break;    

                                 }   

                          case 2:    

                                  cout<<i<<" "<<a<<"x"<<b<<"="<<endl;    

                                  break;   

                          case 3:    

                                         cout<<i<<" "<<a<<"/"<<b<<"="<<endl;    

                                         break;   

                      }  

                }

                 return 0;

    }

     结果截图如下:

  • 相关阅读:
    几道cf水题
    cf水题
    一道cf水题
    c++list用法
    c++map用法
    c++ vector常见用法
    c++string,常见用法总结
    复变函数考试后的反思
    [FZYZOJ 1204] 零和问题
    [FZYZOJ 1202] 金坷垃
  • 原文地址:https://www.cnblogs.com/mudanhuakai/p/4317920.html
Copyright © 2011-2022 走看看