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;

    }

     结果截图如下:

  • 相关阅读:
    golang的make
    Go的指针
    vue 修改子组件的数据$refs
    vue中异步函数async和await的用法
    redis锁
    支付宝app支付商户配置
    微信小程序中this.data与this.setData的区别详解
    jQuery动态数字翻滚计数到指定数字的文字特效代码
    中英文判断
    jQuery点击图片弹出大图遮罩层
  • 原文地址:https://www.cnblogs.com/mudanhuakai/p/4317920.html
Copyright © 2011-2022 走看看