當前位置:編程學習大全網 - 編程軟體 - 用JAVA如何算出24點?

用JAVA如何算出24點?

24點的源代碼,因該可以計算出4則運算24 public class Test24Point{ public static void main(String[] args){ int index = 0 ; int temp = 0 ; int totalSUC = 0 ; int numb[] = new int[4];//the first four numbers double num[][] = new double[36][3];//three numbers after calculating double total[] = new double[6];//the number after three steps of calculating double p[][] = new double[6][8]; double q[][] = new double[3][7]; //System.out.println(2465%108); //System.out.println(2465/108); System.out.println("\"a--b\"means\"b-a\""); System.out.println("\"a//b\"means\"b/a\"\n"); /* for(int h = 0; h <= 9; h ++)//Get the first four numbers for calculating and store into the array numb[4]; for(int i = 0; i <= 9; i ++) for(int j = 0; j <= 9; j ++) for(int k = 0; k <= 9; k ++){ numb[0] = h ; numb[1] = i ; numb[2] = j ; numb[3] = k ; }*/ for(int i = 0 ; i < 4 ; i ++){ numb = Integer.parseInt(args); } for(int i = 0; i < 3; i ++)//Get two of the four to calculate and then store the new number into the array p; for(int j = i + 1; j < 4 ; j ++,temp ++){ p[temp][0] = numb + numb[j]; p[temp][1] = numb - numb[j]; p[temp][2] = numb[j] - numb; p[temp][3] = numb * numb[j]; if(numb[j] != 0) p[temp][4] = numb / (double)numb[j]; else p[temp][4] = 10000; if(numb != 0) p[temp][5] = numb[j] / (double)numb; else p[temp][5] = 10000;

  • 上一篇:函數中的下界是什麽意思
  • 下一篇:簡單談談if語句三種結構的相似和不同之處
  • copyright 2024編程學習大全網