其他分享
首页 > 其他分享> > 9月9日下午课堂测试

9月9日下午课堂测试

作者:互联网

 

import java.util.Scanner;
import java.util.Random;

public class news {

public static void main(String[] args) {

System.out.println("请输入总题目数量:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();


System.out.println("请输入每行题目数量:");
Scanner sc1 = new Scanner(System.in);
int n1 = sc1.nextInt();

System.out.println("请输入数据最大范围:");
Scanner sc2 = new Scanner(System.in);
int n2 = sc2.nextInt();

System.out.println("请输入是否有乘除(1为是0为否):");
Scanner sc3 = new Scanner(System.in);
int n3 = sc3.nextInt();

System.out.println("请输入是否有括号(1为是0为否):");
Scanner sc4 = new Scanner(System.in);
int n4 = sc4.nextInt();

System.out.println("请输入操作符数量:");
Scanner sc5 = new Scanner(System.in);
int n5 = sc5.nextInt();
int n6 = ((n5*2)+2);

int s1=0;

for(int i=0;i<n;i++) {

for(int i1=0;i1<n5;i1++) {braces(n4,n6);rams(n2);braces(n4,n6);symb(n3);}braces(n4,n6);rams(n2);braces(n4,n6);System.out.print("= ");

s1++;
x0=0;
count=0;
point1=0;

if(s1==n1) {

System.out.println(" ");
s1=0;
}
}
//braces(n4)
}

static int x0=0;
static int count=0;
static int point1=0;
public static void braces(int t,int g) {

if(t==1) {

count++;
int x=0;

Random rand = new Random();
x = rand.nextInt(2);

if(x0==2) {

if(x==1&&count<g&&count%2==0) {

System.out.print(")");
x0=3;

}

if(count==g&&x0!=3&&count%2==0) {

System.out.print(")");
x0=3;

}

if(count==(g-2)&&x0!=3&&point1==1) {

System.out.print(")");
x0=3;

}
}

if(x0==1) {

x0=2;

}

if(x0==0) {

if(x==1&&count%2!=0) {

System.out.print("(");
x0=1;
if(count==1) {
point1=1;
}
}
}
}

}

public static void rams(int r) {

Random rand = new Random();

System.out.print(rand.nextInt(r));

}
public static void symb(int x) {

Random rand = new Random();

if(x==1) {

int m1 =rand.nextInt(4);

if(m1==0) {
System.out.print("+");
}
if(m1==1) {
System.out.print("-");
}
if(m1==2) {
System.out.print("*");
}
if(m1==3) {
System.out.print("/");
}
}
else if(x==0) {
int m1 =rand.nextInt(2);

if(m1==0) {
System.out.print("+");
}
if(m1==1) {
System.out.print("-");
}
}
}
}

课堂上没有做完,晚上才做完了。静下心来写还是不难的。

这次课堂测试让我感触良多,深刻意识到了自己的不足,认识到自己今后应该加倍努力

标签:Scanner,int,下午,System,测试,print,课堂,x0,out
来源: https://www.cnblogs.com/rsy-bxf150/p/16676158.html