24点是我们小时候经常会玩的游戏。
4个数字,3个操作符,谁先算出24,谁就胜。

本文利用搜索回溯算法计算24点。

核心思路

我有1,2,3,4这四个数字。如何才能让计算机计算出24来呢?
我们可以这么想,先取出1来,然后让1+2=3,然后再让3+3=6,6+4=10,发现结果不等于24,那我们可以后退一步(回溯)让6-4=2,发现结果也不等,再让6*4=24,结果为24。

图解

abcd代表四个数字

#mermaid-svg-z34CaCnjCo8TDtGw .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-z34CaCnjCo8TDtGw .label text{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .node rect,#mermaid-svg-z34CaCnjCo8TDtGw .node circle,#mermaid-svg-z34CaCnjCo8TDtGw .node ellipse,#mermaid-svg-z34CaCnjCo8TDtGw .node polygon,#mermaid-svg-z34CaCnjCo8TDtGw .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-z34CaCnjCo8TDtGw .node .label{text-align:center;fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .node.clickable{cursor:pointer}#mermaid-svg-z34CaCnjCo8TDtGw .arrowheadPath{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-z34CaCnjCo8TDtGw .flowchart-link{stroke:#333;fill:none}#mermaid-svg-z34CaCnjCo8TDtGw .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-z34CaCnjCo8TDtGw .edgeLabel rect{opacity:0.9}#mermaid-svg-z34CaCnjCo8TDtGw .edgeLabel span{color:#333}#mermaid-svg-z34CaCnjCo8TDtGw .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-z34CaCnjCo8TDtGw .cluster text{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-z34CaCnjCo8TDtGw .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-z34CaCnjCo8TDtGw text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-z34CaCnjCo8TDtGw .actor-line{stroke:grey}#mermaid-svg-z34CaCnjCo8TDtGw .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-z34CaCnjCo8TDtGw .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-z34CaCnjCo8TDtGw #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-z34CaCnjCo8TDtGw .sequenceNumber{fill:#fff}#mermaid-svg-z34CaCnjCo8TDtGw #sequencenumber{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw #crosshead path{fill:#333;stroke:#333}#mermaid-svg-z34CaCnjCo8TDtGw .messageText{fill:#333;stroke:#333}#mermaid-svg-z34CaCnjCo8TDtGw .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-z34CaCnjCo8TDtGw .labelText,#mermaid-svg-z34CaCnjCo8TDtGw .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-z34CaCnjCo8TDtGw .loopText,#mermaid-svg-z34CaCnjCo8TDtGw .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-z34CaCnjCo8TDtGw .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-z34CaCnjCo8TDtGw .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-z34CaCnjCo8TDtGw .noteText,#mermaid-svg-z34CaCnjCo8TDtGw .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-z34CaCnjCo8TDtGw .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-z34CaCnjCo8TDtGw .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-z34CaCnjCo8TDtGw .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-z34CaCnjCo8TDtGw .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .section{stroke:none;opacity:0.2}#mermaid-svg-z34CaCnjCo8TDtGw .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-z34CaCnjCo8TDtGw .section2{fill:#fff400}#mermaid-svg-z34CaCnjCo8TDtGw .section1,#mermaid-svg-z34CaCnjCo8TDtGw .section3{fill:#fff;opacity:0.2}#mermaid-svg-z34CaCnjCo8TDtGw .sectionTitle0{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .sectionTitle1{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .sectionTitle2{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .sectionTitle3{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-z34CaCnjCo8TDtGw .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .grid path{stroke-width:0}#mermaid-svg-z34CaCnjCo8TDtGw .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-z34CaCnjCo8TDtGw .task{stroke-width:2}#mermaid-svg-z34CaCnjCo8TDtGw .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .taskText:not([font-size]){font-size:11px}#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-z34CaCnjCo8TDtGw .task.clickable{cursor:pointer}#mermaid-svg-z34CaCnjCo8TDtGw .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-z34CaCnjCo8TDtGw .taskText0,#mermaid-svg-z34CaCnjCo8TDtGw .taskText1,#mermaid-svg-z34CaCnjCo8TDtGw .taskText2,#mermaid-svg-z34CaCnjCo8TDtGw .taskText3{fill:#fff}#mermaid-svg-z34CaCnjCo8TDtGw .task0,#mermaid-svg-z34CaCnjCo8TDtGw .task1,#mermaid-svg-z34CaCnjCo8TDtGw .task2,#mermaid-svg-z34CaCnjCo8TDtGw .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutside0,#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutside2{fill:#000}#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutside1,#mermaid-svg-z34CaCnjCo8TDtGw .taskTextOutside3{fill:#000}#mermaid-svg-z34CaCnjCo8TDtGw .active0,#mermaid-svg-z34CaCnjCo8TDtGw .active1,#mermaid-svg-z34CaCnjCo8TDtGw .active2,#mermaid-svg-z34CaCnjCo8TDtGw .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-z34CaCnjCo8TDtGw .activeText0,#mermaid-svg-z34CaCnjCo8TDtGw .activeText1,#mermaid-svg-z34CaCnjCo8TDtGw .activeText2,#mermaid-svg-z34CaCnjCo8TDtGw .activeText3{fill:#000 !important}#mermaid-svg-z34CaCnjCo8TDtGw .done0,#mermaid-svg-z34CaCnjCo8TDtGw .done1,#mermaid-svg-z34CaCnjCo8TDtGw .done2,#mermaid-svg-z34CaCnjCo8TDtGw .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-z34CaCnjCo8TDtGw .doneText0,#mermaid-svg-z34CaCnjCo8TDtGw .doneText1,#mermaid-svg-z34CaCnjCo8TDtGw .doneText2,#mermaid-svg-z34CaCnjCo8TDtGw .doneText3{fill:#000 !important}#mermaid-svg-z34CaCnjCo8TDtGw .crit0,#mermaid-svg-z34CaCnjCo8TDtGw .crit1,#mermaid-svg-z34CaCnjCo8TDtGw .crit2,#mermaid-svg-z34CaCnjCo8TDtGw .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-z34CaCnjCo8TDtGw .activeCrit0,#mermaid-svg-z34CaCnjCo8TDtGw .activeCrit1,#mermaid-svg-z34CaCnjCo8TDtGw .activeCrit2,#mermaid-svg-z34CaCnjCo8TDtGw .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-z34CaCnjCo8TDtGw .doneCrit0,#mermaid-svg-z34CaCnjCo8TDtGw .doneCrit1,#mermaid-svg-z34CaCnjCo8TDtGw .doneCrit2,#mermaid-svg-z34CaCnjCo8TDtGw .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-z34CaCnjCo8TDtGw .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-z34CaCnjCo8TDtGw .milestoneText{font-style:italic}#mermaid-svg-z34CaCnjCo8TDtGw .doneCritText0,#mermaid-svg-z34CaCnjCo8TDtGw .doneCritText1,#mermaid-svg-z34CaCnjCo8TDtGw .doneCritText2,#mermaid-svg-z34CaCnjCo8TDtGw .doneCritText3{fill:#000 !important}#mermaid-svg-z34CaCnjCo8TDtGw .activeCritText0,#mermaid-svg-z34CaCnjCo8TDtGw .activeCritText1,#mermaid-svg-z34CaCnjCo8TDtGw .activeCritText2,#mermaid-svg-z34CaCnjCo8TDtGw .activeCritText3{fill:#000 !important}#mermaid-svg-z34CaCnjCo8TDtGw .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-z34CaCnjCo8TDtGw g.classGroup text .title{font-weight:bolder}#mermaid-svg-z34CaCnjCo8TDtGw g.clickable{cursor:pointer}#mermaid-svg-z34CaCnjCo8TDtGw g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-z34CaCnjCo8TDtGw g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-z34CaCnjCo8TDtGw .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-z34CaCnjCo8TDtGw .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-z34CaCnjCo8TDtGw .dashed-line{stroke-dasharray:3}#mermaid-svg-z34CaCnjCo8TDtGw #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw .commit-id,#mermaid-svg-z34CaCnjCo8TDtGw .commit-msg,#mermaid-svg-z34CaCnjCo8TDtGw .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-z34CaCnjCo8TDtGw g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-z34CaCnjCo8TDtGw g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-z34CaCnjCo8TDtGw g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-z34CaCnjCo8TDtGw .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-z34CaCnjCo8TDtGw .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-z34CaCnjCo8TDtGw .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-z34CaCnjCo8TDtGw .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-z34CaCnjCo8TDtGw .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-z34CaCnjCo8TDtGw .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-z34CaCnjCo8TDtGw .edgeLabel text{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-z34CaCnjCo8TDtGw .node circle.state-start{fill:black;stroke:black}#mermaid-svg-z34CaCnjCo8TDtGw .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-z34CaCnjCo8TDtGw #statediagram-barbEnd{fill:#9370db}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-state .divider{stroke:#9370db}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-z34CaCnjCo8TDtGw .note-edge{stroke-dasharray:5}#mermaid-svg-z34CaCnjCo8TDtGw .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-z34CaCnjCo8TDtGw .error-icon{fill:#522}#mermaid-svg-z34CaCnjCo8TDtGw .error-text{fill:#522;stroke:#522}#mermaid-svg-z34CaCnjCo8TDtGw .edge-thickness-normal{stroke-width:2px}#mermaid-svg-z34CaCnjCo8TDtGw .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-z34CaCnjCo8TDtGw .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-z34CaCnjCo8TDtGw .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-z34CaCnjCo8TDtGw .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-z34CaCnjCo8TDtGw .marker{fill:#333}#mermaid-svg-z34CaCnjCo8TDtGw .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}#mermaid-svg-z34CaCnjCo8TDtGw {color: rgba(0, 0, 0, 0.75);font: ;}

a
+
b
+
c
+
d
=24?
-
-
-
*
*
*
/
/
/

图的意思是让a+b+c+d=24是否等于24,不是的话就a+b+c-d=24?
再*d,不等于24话除于d,如果还不等就退回到a+b,让a+b-c+d,不是的话就让a+b-c-d …复返这类操作,直到等于24或无解。

上图中的排列时abcd,但不至于abcd的排列,所以我们要实现全排列的代码

public static void permutations(int[] nums, int start, int end) {if (start == end) {all[countOfall++] = Arrays.copyOf(nums, nums.length);} else {for (int i = start; i < end; i++) {swap(nums, start, i);permutations(nums, start + 1, end);swap(nums, start, i);}}}public static void swap(int[] nums, int a, int b) {int t = nums[a];nums[a] = nums[b];nums[b] = t;}

全排列用递归非常轻易实现,思路就是固定第一个数字,让后面的n-1个数就行全排列,再次固定第二个数字,让n-2个数进行全排列,直到到最后一位。

大体思路已经讲清下面贴出全部代码

import java.util.*;
import static java.lang.System.out;/*** 使用搜索回溯法,返回和为24的公式*/public class Main {static Set<Stack<String>> hashSet = new HashSet<Stack<String>>(); // 去除重复项static char[] syms = new char[]{'+', '-', '*', '/'};static boolean[] visited = new boolean[3]; // 数字是否被访问过, true为访问过,false没有static Stack<String> fu = new Stack<String>(); // 装载公式的栈static int[][] all = new int[24][]; // 装载4个数字的全排列的数组static int countOfall = 0; // all数组的索引public static void main(String[] args) {Scanner sc = new Scanner(System.in);int[] nums = new int[4];out.println("输入四个数字(空格分割):");for (int i = 0; i < nums.length; i++) {nums[i] = sc.nextInt();}permutations(nums, 0, nums.length);nums = new int[3];for (int i = 0; i < all.length; i++) {int numOne = all[i][0];nums = Arrays.copyOfRange(all[i], 1, all[i].length);fu.push(Integer.toString(numOne));resolve(numOne, nums);fu.pop();}/*** 输出所有符合的项*/if (!hashSet.isEmpty()) {for (Stack<String> st : hashSet) {if (!st.isEmpty())out.println(st);}} else out.println("无解");}/*全排列*/public static void permutations(int[] nums, int start, int end) {if (start == end) {all[countOfall++] = Arrays.copyOf(nums, nums.length);} else {for (int i = start; i < end; i++) {swap(nums, start, i);permutations(nums, start + 1, end);swap(nums, start, i);}}}public static void swap(int[] nums, int a, int b) {int t = nums[a];nums[a] = nums[b];nums[b] = t;}/*计算24点的代码num为四个数字的第一个数,nums装载其他3个数需要注意的是除法,因为除法要必须是整除,所以得额外判断,如果不能整除直接放弃这个运算,break出来*/public static void resolve(int num, int[] nums) { if (num == 24 && fu.size() == 7) {hashSet.add((Stack<String>) fu.clone());return;} else if (fu.size() == 7) { // 栈中有个四个数和三个运算符 //但并不符合规则return;}for (int i = 0; i < nums.length; i++) {if (!visited[i]) {for (int j = 0; j < syms.length; j++) {if (syms[j] == '+') {visited[i] = true;fu.push("+");fu.push(Integer.toString(nums[i]));resolve(nums[i] + num, nums);visited[i] = false;fu.pop();fu.pop();} else if (syms[j] == '-') {visited[i] = true;fu.push("-");fu.push(Integer.toString(nums[i]));resolve(num - nums[i], nums);visited[i] = false;fu.pop();fu.pop();} else if (syms[j] == '*') {visited[i] = true;fu.push("*");fu.push(Integer.toString(nums[i]));resolve(nums[i] * num, nums);visited[i] = false;fu.pop();fu.pop();} else {if (num % nums[i] == 0) {visited[i] = true;fu.push("/");fu.push(Integer.toString(nums[i]));resolve(num / nums[i], nums);visited[i] = false;fu.pop();fu.pop();} else break;}}}}}
}

Java代码实现24点计算相关推荐

  1. java JLabel改变大小后如何刷新_到底一行java代码是如何在计算机上执行的

    不知道你是否思考过,每次我们在IDEA中右键Run Application启动主方法,假如程序运行正常,控制台也打印出了你所要打印的信息,在这个过程中你知道这台计算机上那些硬件及其软件都是以什么样的方 ...

  2. 如何以及为什么使用Spoon分析,生成和转换Java代码

    Spoon是分析,生成和转换Java代码的工具. 在本文中,我们将看到通过使用以编程方式处理代码的技术可以实现什么. 我认为这些技术不是很广为人知或使用,这很遗憾,因为它们可能非常有用. 谁知道,即使 ...

  3. 【运筹优化】结合天际线启发式的蚁群算法求解二维矩形装箱问题 + Java代码实现

    文章目录 一.天际线启发式 二.蚁群算法结合天际线启发式 2.1 构建序列 2.1.1 思路一 2.1.2 思路二 2.1.3 思路N 三.Java代码实现 3.1 项目结构 3.2 Ant 3.3 ...

  4. java 根据圆心计算圆弧上点的经纬度_【控制测量学】-高斯投影正算公式以及java代码

    正算公式(将经纬度转化为坐标): java代码(附有源代码和修改后的代码): 源代码: /** * 由经纬度反算成高斯投影坐标 * * @param longitude * @param latitu ...

  5. java实现24点计算

    题目描述 计算24点是一种扑克牌益智游戏,随机抽出4张扑克牌,通过加(+),减(-),乘(*), 除(/)四种运算法则计算得到整数24,本问题中,扑克牌通过如下字符或者字符串表示,其中,小写joker ...

  6. excel总行数 java_计算Excel工作表列中的行数(提供的Java代码)

    参考我之前的问题 How to calculate number of rows in a column of Excel document using Java,我能够计算给定表格中的总列数.现在, ...

  7. 24点游戏java代码 中国开源社区_编程实现一个有GUI的24点游戏

    24点是指从去除大小王后的52张扑克牌中任取 4 张,通过「加.减.乘.除」四则运算得到 24.是一个历史悠久的趣味小游戏. <数据化管理>书中在测试数据敏感度章节提到一个细节" ...

  8. 记录一下 Java 代码实现文件夹、文件的对比,主要包含 word、pdf、文本、图片等相关文件的对比计算,以及计算文本的相似率(重复率)、筛选出差异的文件、方便文件和文档的去重,并封装为jar包

    记录一下 Java 代码实现文件夹.文件的对比,主要包含 word.pdf.文本.图片等相关文件的对比计算,以及计算文本的相似率(重复率).筛选出差异的文件.方便文件和文档的去重,并把所有的源码封装为 ...

  9. 用Java代码计算磁盘里的文件大小

    用Java代码计算磁盘里的文件大小 原理 代码展示 总结 原理 拿到一个文件后我们需要先判断文件是不是标准文件调用isFile()方法,如果是标准文件直接调用length()方法求文件大小,不是标准文 ...

  10. java excel 列数_计算Excel工作表列中的行数(提供的Java代码)

    在参考我之前的问题How to calculate number of rows in a column of Excel document using Java时,我能够计算给定表格中的总列数.现在 ...

最新文章

  1. 怎么用canvas画秒针_用canvas画一个钟表
  2. MySQL 优化实战记录
  3. android toast通知关闭,屏蔽系统通知,Toast无法显示的解决方案 v2.0.0
  4. 商品品牌信息的增删改查操作步骤_javaweb09-Servlet增删改查
  5. 13.JAVA基础:八进制,十六进制表示
  6. SpringBoot集成Dubbo+Zookeeper
  7. 先学python再学c_初学者Python和C先学哪个好?
  8. 软件测试用例编号命名规则,在TD的测试用例中显示测试用例编号的方法
  9. Tilera-Pro64 支持Broadcom HiGig标签
  10. 如何购买银行理财子公司的理财产品?
  11. 请不要嘲笑有梦想的罗永浩
  12. pytest合集(5)— Function函数
  13. python-can简述
  14. 前端将时间格式‘2020-03-03T16:49:18.000+0000‘转化成正常格式‘2020-03-03 16:49:18‘ _@jie
  15. 完美国际真数苹果_让苹果数据线下岗的两款数据线!剪断了还能用!
  16. 如何利用开关量信号传输装置实现工厂智能化技改?
  17. Hello World | 每个被生活暴击的成年人,都要学会按重启键
  18. 关于springboot项目连接oracle数据库报错 ORA01017的改正
  19. 一种分布式深度学习编程新范式:Global Tensor
  20. IOS-手机来电或者第三方音频打断当前播放

热门文章

  1. 手写板(数位板)如何和希沃白板5无缝切换
  2. C#中使用SHFileOperation调用Windows的复制文件对话框
  3. 微软服务器监控软件,Windows监控,Windows监控软件
  4. DevExpress GridView 排序状态下新增行不参与排序
  5. 一些css/css3特效以及边框流光特效实现
  6. 电商seo培训之卖家搜索优化步骤
  7. 快速清理C盘的四个方法
  8. 金蝶连服务器显示演示版,金蝶正版和金蝶演示版的区别
  9. dvi黑屏解决方法_DVI线导致黑屏故障处理全攻略
  10. Unity给力插件之ShaderForge