题目见图片附件
Seven:
[Java] 纯文本查看 复制代码 import java.util.Scanner;
public class Seven {
static int user1, user2;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请玩家1输入石头、剪刀或者布:");
String a = sc.nextLine();
System.out.println("请玩家2输入石头、剪刀或者布:");
String b = sc.nextLine();
user1 = exchange(a, user1);
user2 = exchange(b, user2);
check(user1, user2);
}
private static void check(int user1, int user2) {
if (user1 == user2) {
System.out.println("平局");
return;
}
if (user1 == 0) {
if (user2 == 2) {
System.out.println("玩家1Win");
} else {
System.out.println("玩家2Win");
}
} else if (user1 == 2) {
if (user2 == 0) {
System.out.println("玩家2Win");
} else {
System.out.println("玩家1Win");
}
} else if (user1 == 5) {
System.out.println("玩家2Win");
} else {
System.out.println("玩家1Win");
}
}
private static int exchange(String x, int n) {
if ("剪刀".equals(x)) {
n = 2;
} else if ("石头".equals(x)) {
n = 0;
} else {
n = 5;
}
return n;
}
}
Eight:
[Asm] 纯文本查看 复制代码 public class Corporation {
double salary;
int hour;
public Corporation(double salary, int hour) {
this.salary = salary;
this.hour = hour;
}
void getMoney() {
if (this.salary < 8.0 || this.hour > 60) {
System.out.println("Declined to 996");
return;
}
double m = this.hour * this.salary;
if (this.hour <= 40) {
System.out.println(m);
} else {
System.out.println(m + (this.hour - 40 * 1.5));
}
}
}
public class Main {
public static void main(String[] args) {
Corporation user1 = new Corporation(7.50,35);
Corporation user2 = new Corporation(8.20,47);
Corporation user3 = new Corporation(10.00,73);
user1.getMoney();
user2.getMoney();
user3.getMoney();
}
}
Nine:
[Java] 纯文本查看 复制代码 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Nine {
public static void main(String[] args) throws IOException {
System.out.println("请输入个数及其差值");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] s = br.readLine().split(" ");
int cnt = Integer.parseInt(s[0]);
int dif = Integer.parseInt(s[1]);
System.out.println("输入" + cnt +"个整数");
String[] s1 = br.readLine().split(" ");
int [] arr = new int[s1.length];
for(int i = 0 ;i<arr.length;i++){
arr[i] = Integer.parseInt(s1[i]);
}
for(int i = 0;i<arr.length-1;i++){
if (Math.abs(arr[i] - arr[i+1]) >dif){
System.out.println("数列从" + ++i + "个数开始中断");
return;
}
}
System.out.println("这是" + cnt + "个数组组成的连续数列,差值为" + dif );
}
}
在新标签打开所有链接复制所有链接URL复制所有链接URL(反向)复制所有链接标题 + URL复制所有链接标题 + URL (MD)复制所有链接标题 + URL (BBS)复制所有链接标题 + URL (筛选)复制所有链接标题 + URL (设置复制格式)在新标签页打开所有图片链接在一个标签页显示所有图片链接
复选框 - 选中
复选框 - 取消
复选框 - 反选
单选框 - 选中
单选框 - 取消
特殊单选框 - 选中 |