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

    实验大致实现了四个功能:

    1.询问是否需要乘除法,用两个chengchu()函数实现;

    2.询问定制的题目数,用b来控制循环的次数;

    3.询问加减法是否需要负数,用两个jiajian()函数实现;

    4.询问输入数的范围,通过改变rand()%d中d的大小来实现。

    下面是我粗糙的小实验:

    #include<iostream.h>

    #include<time.h>

    #include<stdlib.h>

    #include<stdio.h>

    void  chengchu1()

    {   int d;

        int x,y;

        int m;

        x=rand()%d;

        y=rand()%d;

        m=rand()%4;

        if(m==0)

          cout<<x<<'+'<<y<<'='<<endl;

        if(m==1&&x>=y)

          cout<<x<<'-'<<y<<'='<<endl;

        if(m==2)

          cout<<x<<'*'<<y<<'='<<endl;

        if(m==3&&y!=0)

          cout<<x<<'/'<<y<<'='<<endl;

    }

    void  chengchu2()

    {   

    int d;

        int x,y;

        int m;

        x=rand()%d;

        y=rand()%d;

        m=rand()%4;

        if(m==3)

          cout<<x<<'*'<<y<<'='<<endl;

        if(m==4&&y!=0)

          cout<<x<<'/'<<y<<'='<<endl;

    }

    void  jiajian1()

    {  

    int d;

        int x,y;

        int m;

        x=rand()%d;

        y=rand()%d;

        m=rand()%4;

        if(m==0&&x>0&&y>0)

          cout<<x<<'+'<<y<<'='<<endl;

        if(m==1&&x>=y&&x>0&&y>0)

          cout<<x<<'-'<<y<<'='<<endl;

        if(m==2)

          cout<<x<<'*'<<y<<'='<<endl;

        if(m==3&&y!=0)

          cout<<x<<'/'<<y<<'='<<endl;

    }

    void  jiajian2()

    {  

    int d;

        int x,y;

        int m;

        x=rand()%d;

        y=rand()%d;

        m=rand()%4;

        if(m==3&&x>0&&y>0)

          cout<<x<<'*'<<y<<'='<<endl;

        if(m==4&&y!=0&&x>0&&y>0)

          cout<<x<<'/'<<y<<'='<<endl;

    }

    int main()

    {   

    int i;

    int a,b,c,d;

    cout<<"需要乘除法吗?需要请输入1:;不需要请输入2"<<endl;

    cin>>a;

    cout<<"定制题目数:"<<endl;

    cin>>b;

    cout<<"加减需要有负数吗?需要请输入1;不需要请输入2"<<endl;

    cin>>c;

    cout<<"输入数的范围:"<<endl;

    cin>>d;

    if(c=1)

    {

    if(a=1)

    {

    for(i=0;i<b;i++)

    chengchu1();

    }

    else 

    {

    for(i=0;i<b;i++)

                chengchu2();

    }

    }

    else

    {

            if(a=1)

    {

    for(i=0;i<b;i++)

    jiajian1();

    }

    else 

    {

    for(i=0;i<b;i++)

                            jiajian2();

    }

    }

        cout<<"Finished!Congratulations!";

        return 0;

    }

    实验心得:

    其实刚开始拿到这个题目,我的内心是抗拒的额,因为我觉得会特别难,所以我犹豫了很久才出手,但是开始做之后真的发现其实很多东西没有我们想的那么的难,因为自开始做后,我的程序估计是因为太简单,它没有出错,这是个好的开端。当开始编程时,我就知道这不是终点,这是个开始。。。。

    PSP三张表:

     学生:万彤

    日期:3.15

    教师:王建民

                                                                                                      项目计划总结

     

    编程

    完善程序

    测试程序

    阅读书籍

    日总计

    周日

     

     

     

    11:00-11:30

     pm

    0.5

    周一

     

     

     

    11:00-11:30

     pm

    0.5

    周二

     

     

     

     11:00-11:30

     pm

    0.5

    周三

     

     

     

    11:00-11:30

     pm

    0.5

    周四

    21:00-22:30

     pm

     

     

    11:00-11:30

     pm

    2.0

    周五

     22:00-22:30

     pm

     

     

    11:00-11:30

     pm

    1.0

    周六

     12:30-3:30

    pm

     

    3:30-4:30

    pm

    11:00-11:30

     pm

    1.0

    周总计

    5.0

     

    1.0

    3.5

    9.5

     时间记录总结

     

    日期

    开始

    结束

    中断时间

    净时间

    活动

    备注

    C

    U

    312

    21:00

    22:30

    1.5

    编程

     

     

     

    3月13日

    22:00

    22:30

    0.5

    编程

     

     

     

    3月14日

    12:30

    15:30

    30min

    2.5

    编程和测试

     中途休息

     

     

    缺陷记录日志

     

     

     

    日期

    编号

    类型

    引入阶段

    排除阶段

    修复时间

    修复缺陷

    3.13.2015

    01

    程序

    编码

    编译

    20min

    不会定义全局变量,未修复

    3.14.2015

    02

    程序

    编码

    编译

    30min

    调用函数

    3.14

    03

    程序

    编码

    编译

    60min

    测试程序,修复变量

  • 相关阅读:
    调试技术能够让新技术的学习事半功倍
    世界500强绩效考核(KPI) [11]
    .NET 4.0新功能介绍:In Process Side By Side
    What's New in the .NET Framework Version 4
    Production Debugging for .NET Framework Applications
    Project 2007下的自动计算问题
    SQL操作全集
    WPF1.1 理解Windows图形
    .NET Framework Version 4 Application Compatibility Walkthrough
    Fixing BizTalk ENTSSO Failure on Windows 7, Vista or Server 2008 after .NET 4.0 Installation
  • 原文地址:https://www.cnblogs.com/wantong/p/4337693.html
Copyright © 2011-2022 走看看