今天背了20个单词,然后就是上体育课学了篮球方面的知识。然后下午就是上离散数学课
练习题:求猴子大王
import java.util.Scanner;import java.lang.Math;
import java.util.HashMap;
import java.util.Map;
public class MonkeyKing {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int [] index = new int[N];
for (int i = 0; i < N; i++) {
index[i] = 1;
}
int n = N; //圈子中剩余的猴子数目
int b = 0; //报数
while (n > 1) {
for (int j = 0; j < N; j++) {
b += index[j];
if (b == 3) {
index[j] = 0;
n--;
b = 0;
}
}
}
for (int k = 0; k < N; k++) {
if (index[k] != 0) {
System.out.println(k+1);
}
}
}
}
标签:index,java,14,int,天气,util,2023,import,Scanner From: https://www.cnblogs.com/Christmas77/p/17703501.html