zoukankan      html  css  js  c++  java
  • 软件工程个人作业01

    设计思路:定义四个数组,其中两个用于算数,一个用于随机,根据其结果输出算法,最后一个用于随机整数运算还是分数运算

    package 课堂;
    import java.util.Random;
    
    public class sizeyusuan
    {
        static void fuhao(int value)
        {
            if(value == 0)
            {
                System.out.print(" + ");
            }
            if(value == 1)
            {
                System.out.print(" - ");
            }
            if(value == 2)
            {
                System.out.print(" * ");
            }
            if(value == 3)
            {
                System.out.print(" / ");
            }
        }
        public static void main(String args[])
        {
            int []Array = new int[30];int []Array1 = new int[30];
            int []judge = new int[30];int []Array2 = new int[30];
            for(int i = 0;i < 30;i++)
            {
                Array[i] = new Random().nextInt(100);
                Array1[i] = new Random().nextInt(100);
                Array2[i] = new Random().nextInt(4);
                judge[i] = new Random().nextInt(2);
            }
            for(int i = 0;i < 30;i++)
            {
                if(judge[i] == 0)
                {
                    while(Array2[i] == 3 && Array1[i] == 0)
                    {
                        Array1[i] = new Random().nextInt(100);
                        if(Array1[i] != 0)
                        {
                            break;
                        }
                    }
                    System.out.print(Array[i]);
                    fuhao(Array2[i]);
                    System.out.println(Array1[i] + " = ");
                }
                if(judge[i] == 1)
                {
                    int a = new Random().nextInt(100);
                    int b = new Random().nextInt(100);
                        
                    while(Array2[i] == 3)
                    {
                        if(Array1[i] == 0)
                        {
                            Array1[i] = new Random().nextInt(100);
                        }
                        if(b == 0)
                        {
                            b = new Random().nextInt(100);
                        }
                        if(Array[i] != 0 && b != 0)
                        {
                            break;
                        }
                    }
                    
                    if(Array[i] > Array1[i])
                    {
                        int t = Array[i];
                        Array[i] = Array1[i];
                        Array[i] = t;
                    }
                    if(a > b)
                    {
                        int t = a;
                        a = b;
                        b = t;
                    }
                    
                    System.out.print("(" + Array[i] + "/" + Array1[i] + ")");
                    fuhao(Array2[i]);
                    System.out.println("(" + a + "/" + b + ") = ");
                }
            }
        }
    }



    课上未完成的原因。
      没有优化,数组超出范围。
  • 相关阅读:
    顶目群定义及项目群管理
    项目管理与项目组合管理的不同
    IT项目经理:人际关系技能和领导技能的重要性
    IT 项目经理的职业生涯
    Sharepoint2010 中隐藏 "快速启动"与"最近修改'
    3 个基本的IT项目组合种类
    项目成功的标志及决定因素
    HDL,你们作对了吗?
    JAVA代码编写的30条建议
    八款开源 Android 游戏引擎
  • 原文地址:https://www.cnblogs.com/shenshenxin/p/5266138.html
Copyright © 2011-2022 走看看