لسلام عليكم و رحمه الله و بركاته اتمنى من احد ان يساعدني و جزاه الله الف خير فانى بحاجه ماسه للمساعده
ارجوا ان اجد الاجابه بهذا المنتدى الجميل
لا ادري ما اخطا في برنامجي :
السؤال:
لدينا مصفوفه , كل خانه في هذه المصفوفه لها قيمه و المطلوب ايجاد طريق من اول المصفوفه إلى اخر عمد فيها بحيث يكون هذا الطريق ذو اقل قيمه
مثلا شوف اللون الاحمربس لا تهتم باللي بالون الازرق:
1-يطلب من اليوزر يدخل موقع اي خليه من العمود الاول(في هذخه الحاله دخل 5و0 اللي قيمته 3
2- البرنامج بس يقدر يمشي
i,j+1
i-1,j+1
i+1,j+1
عشان يلقه الطريق اللي تكون قيمته اقل بحيث ان كل خليه موجود قيمتها عليها
each cell in the matrix has an associated cost. You begin in the leftmost column and select a starting cell. You may not move up or down an element in the same column, you must always move to the next column towards the right; moving either diagonally or directly to the cell on the right. The goal of the problem is to minimize the cost traveling from left-most to the right-most column such that the sum of the cost of each cell along the path is at a minimum.

ارجو ان تساعدني
و جزاك الله الف خير
حلي و لكنه لايعمل و ربما غير صحيح
public class min_matrix_path {
private Random rand;
private int [][] table={{16,5,4,6},{2,5,1,9},{8,7,6,5},{4,3,2,1}};
private int []vact ;
private int []vactend;
private int som,n;
public min_matrix_path(int n)
{
rand=new Random();//rand.nextint(100);
//table=new int[n][n];
vact=new int [n];
vactend=new int[n];
this.n=n;
}
public int min_matrix(int i,int j,int s)
{s=s+table[j];
vact[j]=i;
if(j==n && s<som)
{som=s;
vactend=vact;
}
else
min_matrix(i,j+1,s);
if(i<n-1)
min_matrix(i+1,j+1,s);
else if (i>0)
min_matrix(i-1,j+1,s);
return som;
}
public static void main(String[] args) {
min_matrix_path A= new min_matrix_path(4);
A.min_matrix(1,0,4);
}
}