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

    程序设计思想:

    在原有代码封基础上,重新封装符号和除余查看是否存在的类,在主函数加以调用即可。

    源代码:

      1 package test;
      2 import java.lang.*;
      3 import java.util.*;
      4 
      5 public class test {
      6     /*public static   void zhenfenshu(Shu A){
      7         if(A.a/A.d>1||A.b/A.e>1)
      8         {
      9             A.shu();
     10         }
     11     }*/
     12     public static Boolean chachong1(Shu x,Shu y){
     13         if(x.a/x.d==y.a/y.d&&x.b/x.e==y.b/y.e&&x.c==y.c)
     14         {
     15             return true;
     16         }
     17         else if(x.a/x.d==y.d/y.e&&x.b/x.e==y.a/y.d&&x.c==y.c)
     18         {
     19             return true;
     20         }
     21         else{return false;}
     22     }
     23 
     24     public static void main(String args[]){
     25         int i;
     26         System.out.println("请输入要输出的题数:");
     27         Scanner num=new Scanner(System.in);
     28         int n = num.nextInt();
     29         Shu s[]=new Shu [n];    
     30             for(i=0;i<n;i++){
     31                 s[i]=new Shu();
     32                 boolean ss=true;
     33                 //zhenfenshu(s[i]);
     34                 while(ss){
     35                     ss=false;
     36                     s[i].shu();
     37                     for(int j=0;j<i;j++){
     38                         if(chachong1(s[i],s[j])){
     39                             ss=true;
     40                         }
     41                     }
     42                 }
     43             }
     44             for(i=0;i<n;i++)
     45             {
     46                 s[i].show();
     47             }
     48             }
     49 }
     50 class Shu{
     51     int a,b,c,d,e;
     52     int s1,s2,s3,s4;
     53     public  void shu(){
     54         a = (int)(Math.random()*100);
     55         d = (int)(Math.random()*100);
     56         e = (int)(Math.random()*100);
     57         b = (int)(Math.random()*100);
     58         c = (int)(Math.random()*3);
     59     }
     60     public void show(int a2,int a3){
     61         if(a2==1&&a3==1){
     62             daifuhao();
     63             int m1=0,m2=0;
     64             this.suiji(m1,m2);
     65             m1=(int)(Math.random()*(n-1));
     66             m2=(int)(Math.random()*(n-1)+2);
     67             while(m2<m1+2){
     68                 m2=(int)(Math.random()*(n-1)+2);
     69             }
     70             for(int i=0;i<m1;i++){
     71                 System.out.print(a[i]+zhuan(f[i]));
     72             }
     73             System.out.print("(");
     74             for(int i=m1;i<m2-1;i++){
     75                 System.out.print(a[i]+zhuan(f[i]));
     76             }
     77             System.out.print(a[m2-1]);
     78             System.out.print(")");
     79             if(m2-1<n-1)System.out.print(zhuan(f[m2-1]));
     80             for(int i=m2;i<n-1;i++){
     81                 System.out.print(a[i]+zhuan(f[i]));
     82             }
     83             if(m2!=n)System.out.print(a[n-1]);
     84         }
     85         else if(a2==1&&a3==2){
     86             daifuhao();
     87             for(int i=0;i<n-1;i++){
     88                 System.out.print(a[i]+zhuan(f[i]));
     89             }
     90             System.out.print(a[n-1]);
     91         }
     92         else if(a2==2&&a3==1){
     93             int m1=0,m2=0;
     94             this.suiji(m1,m2);
     95             m1=(int)(Math.random()*(n-1));
     96             m2=(int)(Math.random()*(n-1)+2);
     97             while(m2<m1+2){
     98                 m2=(int)(Math.random()*(n-1)+2);
     99             }
    100             for(int i=0;i<m1;i++){
    101                 System.out.print(a[i]+zhuan(f[i]));
    102             }
    103             System.out.print("(");
    104             for(int i=m1;i<m2-1;i++){
    105                 System.out.print(a[i]+zhuan(f[i]));
    106             }
    107             System.out.print(a[m2-1]);
    108             System.out.print(")");
    109             if(m2-1<n-1)System.out.print(zhuan(f[m2-1]));
    110             for(int i=m2;i<n-1;i++){
    111                 System.out.print(a[i]+zhuan(f[i]));
    112             }
    113             if(m2!=n)System.out.print(a[n-1]);
    114         }
    115         else{
    116             for(int i=0;i<n-1;i++){
    117                 System.out.print(a[i]+zhuan(f[i]));
    118             }
    119             System.out.print(a[n-1]);
    120         }
    121         System.out.println("=");
    122     }    
    123 }

    输出图像:

  • 相关阅读:
    LAMP环境搭建
    Httpd
    MySQL常用配置和性能压力测试:MySQL系列之十五
    MySQL的高可用实现:MySQL系列之十四
    MySQL的复制:MySQL系列之十三
    备份与恢复:MySQL系列之十二
    日志记录:MySQL系列之十一
    事务隔离实现并发控制:MySQL系列之十
    SpringMVC上传文件(图片)并保存到本地
    W10如何开启LinuxBash及安装Ubuntu
  • 原文地址:https://www.cnblogs.com/bai123/p/6532514.html
Copyright © 2011-2022 走看看