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;

    }

     结果截图如下:

  • 相关阅读:
    AS400一些有用的命令
    Publish的时候某些需要用到的文件没deploy上去
    DB2一些SQL的用法
    根据PostgreSQL 系统表查出字段描述
    linux memcached 安装
    CentOS下XEN虚拟服务器安装配置
    Apache the requested operation has failed
    PHP配置兼容ZendDebugger和Optimizer
    虚拟机比较
    memcache 运行情况,内存使用
  • 原文地址:https://www.cnblogs.com/mudanhuakai/p/4317920.html
Copyright © 2011-2022 走看看