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

    
    
    
    

    设计思想:延续上题,增加要求  

      是否有乘除法

      是否有括号

    数值范围

    加减有无负数
    乘除有无余数 
    括号的使用暂时还不太明白如何使用,惩处发可以通过数组内选择性的随意符号,便可以实现。数值范围通过一个变量来控制随机数的生成来实现,有无负数,可以加入条件来除去负数的式子。

    1
    //张生辉 20153119 四则运算 2 package sizeyunsuan; 3 import java.util.*; 4 public class main { 5 static int i; 6 static int n; 7 public static void main(String args[]){ 8 int dzs;//定制题的数目; 9 int js = 1;//题目序号计数; 10 int panduan=1; 11 System.out.println("是否包含假分数?如不需要请输入1,需要则输入0;"); 12 Scanner first = new Scanner(System.in); 13 int l = first.nextInt();//判断是否为假分数 14 System.out.println("请输入定制题目数量:"); 15 Scanner scanner = new Scanner(System.in); 16 dzs=scanner.nextInt(); 17 int number[]=new int[1000]; 18 char fu[]=new char[500]; 19 char c[]={'+','-','*','/'}; 20 //生成题目的随机数数组 21 for(i=0;i<1000;i++) 22 { 23 int x=(int)(Math.random()*100); 24 number[i]=x; 25 } 26 //生成随机符号的数组 27 for(i=0;i<500;i++) 28 { 29 Random random=new Random(); 30 int index=random.nextInt(c.length); 31 char resultChar=c[index]; 32 fu[i]=resultChar; 33 } 34 //输出题目 35 for(n=0;n<dzs;n++) 36 { 37 38 if(l==panduan)//不需要假分数 39 { 40 int a = number[n]; 41 int b = number[n+99]; 42 char h = fu[n]; 43 if(b>a&&h=='/') 44 { 45 System.out.print(js+". "); 46 System.out.print(a); 47 System.out.print(h); 48 System.out.print(b); 49 System.out.println(" ="); 50 js++; 51 } 52 53 } 54 if(l!=panduan )//需要假分数 55 { 56 int a = number[n]; 57 int b = number[n+99]; 58 char h = fu[n]; 59 System.out.print(js+". "); 60 System.out.print(a); 61 System.out.print(h); 62 System.out.print(b); 63 System.out.println(" ="); 64 js++; 65 } 66 } 67 } 68 }
    
    
    
     项目计划日志:

    缺陷日志:
     
     
  • 相关阅读:
    从操作系统拖拽图片到指定区域进行预览
    原生拖拽,拖放事件(drag and drop)
    H5原生拖拽事件
    css3滚动提示
    通过模糊来弱化背景
    js获取url的各项参数
    垂直居中 解决方法
    紧贴底部的页脚
    实现html元素跟随touchmove事件的event.touches[0].clientX移动
    前端方面值得尊敬的大神们
  • 原文地址:https://www.cnblogs.com/shenghuizhang/p/6531387.html
Copyright © 2011-2022 走看看