fork(1) download
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. //Thuat toan quay lui
  8. public class ThuatToanQuayLui {
  9.  
  10. int [] kq, chon, v;
  11. int n, dem=0;
  12.  
  13. //Khởi tạo giá trị
  14. void khoitao()
  15. {
  16. n = 8;
  17. v = new int[n];
  18. v[0] = 5 ; v[1] = 2; v[3] = 4; v[4] = 8; v[5] = 9; v[6] = 7; v[7] = 5;
  19. chon = new int[n];
  20. kq = new int[n];
  21. for(int j=0;j<n;j++)
  22. chon[j] = kq[j] = 0;
  23. }
  24.  
  25. //In kết quả
  26. void inkq()
  27. {
  28. System.out.println("\n Cach thu" + ++dem + ":");
  29. for(int j=0;j<n;j++)
  30. System.out.println(""+ kq[j]);
  31.  
  32. }
  33.  
  34. //Tìm số hợp lý
  35. void tim(int i, int d)
  36. {
  37. if(i>n) inkq();
  38. else
  39. for(int j=0; j<n; j++)
  40. {
  41. if(chon[j]==0 && v[j]>d)// Nếu bình xăng chưa được chọn và có thể bay
  42. {
  43. kq[i-1] = v[j]; chon[j]=1;// Lấy bình xăng và đánh dấu đã đỗ.
  44. tim(i+1, v[j]-d);
  45. kq[i-1] = 0; chon[j]=0;
  46.  
  47. }
  48. }
  49. }
  50.  
  51. public static void main(String[]args){
  52. ThuatToanQuayLui m = new ThuatToanQuayLui();
  53. int d=2;
  54. m.khoitao();
  55. m.tim(1,d);
  56. }
  57. }
  58.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: class ThuatToanQuayLui is public, should be declared in a file named ThuatToanQuayLui.java
public class ThuatToanQuayLui {
       ^
1 error
stdout
Standard output is empty