突然想到的一个很有意思的题

0

T-MAC泛泛之交 | 初学一级 | 园豆：192

0

public static void main(String[] args) {
Map<Integer,Integer> map = new HashMap<>();
List<Integer> list1 = new ArrayList<>();
int a0 = 0;
int a1 = 0;
int a2 = 0;
int a3 = 0;
int a4 = 0;
int a5 = 0;
int a6 = 0;
int a7 = 0;
int a8 = 0;
int a9 = 0;
int time = 0;
List<String> list = new ArrayList<>();
for (int k = 0; k < 24; k++) {
int minutes = 0;
for (int j = 0; j < 60; j++) {
int second = 0;
for (int i = 0; i < 60; i++) {
String data;
if (k < 10) {
if (j < 10) {
if (i < 10) {
data = 0 + "" + time + "" + 0 + minutes + "" + 0 + second;
} else {
data = 0 + "" + time + "" + 0 + minutes + "" + second;
}
} else {
if (i < 10) {
data = 0 + "" + time + "" + minutes + "" + 0 + second;
} else {
data = 0 + "" + time + "" + minutes + "" + second;
}
}
} else {
if (j < 10) {
if (i < 10) {
data = time + "" + 0 + minutes + "" + 0 + second;
} else {
data = time + "" + 0 + minutes + "" + second;
}
} else {
if (i < 10) {
data = time + "" + minutes + "" + 0 + second;
} else {
data = time + "" + minutes + "" + second;
}
}
}
second++;
}
minutes++;
}
time++;
}

``````    Iterator<String> iterator = list.stream().iterator();
while (iterator.hasNext()){
String next = iterator.next();
String[] split = next.split("");
for (String s1 : split){
switch (Integer.parseInt(s1.trim())){
case 0:a0++;break;
case 1:a1++;break;
case 2:a2++;break;
case 3:a3++;break;
case 4:a4++;break;
case 5:a5++;break;
case 6:a6++;break;
case 7:a7++;break;
case 8:a8++;break;
case 9:a9++;break;
}
}
}
map.put(0,a0);
map.put(1,a1);
map.put(2,a2);
map.put(3,a3);
map.put(4,a4);
map.put(5,a5);
map.put(6,a6);
map.put(7,a7);
map.put(8,a8);
map.put(9,a9);
System.out.println(map);
}
``````

}

T-MAC泛泛之交 | 园豆：192 (初学一级) | 2021-04-27 22:31

0

echo_lovely | 园豆：903 (小虾三级) | 2021-03-17 16:22

@小草上飞飞: 数字形式的时间

@T-MAC泛泛之交: 等我明天给你写个C# 的，枚举一天的秒数计算下，反正计算机算的，又不是我数的。

@T-MAC泛泛之交: 24小时制

0

0

0

schips | 园豆：202 (菜鸟二级) | 2021-03-30 15:37

您需要登录以后才能回答，未注册用户请先注册