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