zoukankan      html  css  js  c++  java
  • 2015430 加法阶段一的封装测试

    public class fdgfg
    {
        Vector<Expression> v;
        public fdgfg()
        {
            v = new Vector<Expression>();
        }
        public void produceExpression(int bit,char operator)
        {
            Expression temp = new Expression();
            temp.operator = operator;
            temp.a = (int)(Math.random() * Math.pow(10,bit));
            temp.b = (int)(Math.random() * Math.pow(10,bit));
            switch (operator) 
            {
                case '+': temp.c = temp.a + temp.b;break;
                case '-': temp.c = temp.a - temp.b;break;
                case '*': temp.c = temp.a * temp.b;break;
                case '/': temp.b = (temp.b == 0 ? //排除除法被除数为0的情况
                          temp.b = 1 +(int)(Math.random() * Math.pow(10,bit)-1): temp.b);
                          temp.c = temp.a / temp.b;break;
                default : core(temp,bit);//封装混合运算测试
            }
     
            v.add(temp);
        }
        //混合运算的封装测试
        public void core(Expression temp,int bit)
        {
            int rand  = (int)(Math.random()*4);
            switch(rand)
            {
                case 1: temp.c = temp.a + temp.b;temp.operator = '+';break;
                case 2: temp.c = temp.a - temp.b;temp.operator = '-';break;
                case 3: temp.c = temp.a * temp.b;temp.operator = '*';break;
                case 0: temp.b = (temp.b == 0 ? //排除除法被除数为0的情况
                        temp.b = 1 +(int)(Math.random() * Math.pow(10,bit)-1): temp.b);
                        temp.c = temp.a / temp.b;temp.operator = '/';break;
                default :
            }
        }


    任务分配: 29罗凯旋 完成阶段一的任务

    伙伴 25廖灼燊 http://www.cnblogs.com/liaozhuoshen/p/4369428.html

  • 相关阅读:
    判断一个大于1的数是不是一个素数
    luogu P3241 [HNOI2015]开店
    换根DP
    CF1187E Tree Painting
    luogu P3345 [ZJOI2015]幻想乡战略游戏
    费用流
    FZOJ 4112 脱单计划
    计数DP
    FZOJ 4109 青青草原的表彰大会
    状压DP
  • 原文地址:https://www.cnblogs.com/kasion/p/4469261.html
Copyright © 2011-2022 走看看