<identifier> expected public void minimumcost(table)
32. satırda bu hatayıveriyor
bir de &裟)&裟expected yazıyor.
Java konusunda bilgisi olan bir arkadaş ilgilenebilrise sevinirim.
import javax.swing.*;
import java.util.Random;
import java.util.Arrays;
import java.lang.String;
public class Project
&褳
int [][]table=&褳//We have 10x10 array
&褳0,550,0,0,50,0,0,0,0,0,50},//ROW1
&褳0,0,150,200,0,200,0,0,0,0},//ROW2
&褳0,0,0,0,0,150,0,0,0,0},//ROW3
&褳0,0,0,0,0,200,0,0,0,0},//ROW4
&褳0,0,0,0,0,0,100,0,0,0},//ROW5
&褳0,0,0,0,0,0,0,500,0,0},//ROW6
&褳0,0,0,0,0,100,0,100,0,0},//ROW7
&褳0,0,0,0,0,0,0,0,600,0},//ROW8
&褳0,0,0,0,0,0,0,0,0,0},//ROW9
&褳0,0,0,0,0,0,50,0,0,0}//ROW10
};
public void main(String[]args)
&褳
System.out.println("We have the minimum cost in this sequence:");
MinimumCost(table);
}
public void MinimumCost(int[][]table)
&褳
int factorialNine=factorial(9);//When we put the first element on the array ,there is left 9! possibilities
//to put the other numbers.Below ,we say row i 9!
int[][]oneLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 1
int[][]twoLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 2
int[][]threeLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 3
int[][]fourLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 4
int[][]fiveLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 5
int[][]sixLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 6
int[][]sevenLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 7
int[][]eightLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 8
int[][]nineLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 9
int[][]tenLeadArrays=new int[factorialNine][10];//Whole possibilities of the array that starts with 10
//LoadLeadArray fills the array with all possibilities that starts with index number in the function;i.e here it is 0
oneLeadArrays=LoadLeadArray(1);
twoLeadArrays=LoadLeadArray(2);
threeLeadArrays=LoadLeadArray(3);
fourLeadArrays=LoadLeadArray(4);
fiveLeadArrays=LoadLeadArray(5);
sixLeadArrays=LoadLeadArray(6);
sevenLeadArrays=LoadLeadArray(7);
eightLeadArrays=LoadLeadArray(8);
nineLeadArrays=LoadLeadArray(9);
tenLeadArrays=LoadLeadArray(10);
int holdSmallestOneLead=SmallestCost(oneLeadArrays,table);
int holdSmallestTwoLead=SmallestCost(twoLeadArrays,table);
int holdSmallesthreeOneLead=SmallestCost(threeLeadArrays,table);
int holdSmallestFourLead=SmallestCost(fourLeadArrays,table);
int holdSmallestFiveLead=SmallestCost(fiveLeadArrays,table);
int holdSmallestSixLead=SmallestCost(sixLeadArrays,table);
int holdSmallestSevenLead=SmallestCost(sevenLeadArrays,table);
int holdSmallestEightLead=SmallestCost(eightLeadArrays,table);
int holdSmallestNineLead=SmallestCost(nineLeadArrays,table);
int holdSmallestTenLead=SmallestCost(tenLeadArrays,table);
}
public int factorial(int number)
&褳
if(number==1)
return 1;
else
&褳
return number*(number-1);
}
}
public int [][] LoadLeadArray(int index)//
&褳
Random random=new Random();
int[][]hold=new int[factorial(9)][];
int i=0;
for(;i<factorial(9);i++)//We start to put elements in the array from index 1
&褳
if(i==0)//If we are at 0,there is no need to check the other rows if they&裟re equal or not.Otherwise,we have to check
&褳
hold[i][0]=index;
for(int j=1;j<=9;j++)
&褳
int holdRandom=1+(int)(Math.random()*10);//It creates random number between 1 and 10; one and nine included
while(holdRandom==index)
&褳
holdRandom=1+(int)(Math.random()*10);
}
if(ArrayCheck(hold_hold,holdRandom,j,hold[i][j]))
&褳
hold[i][j]=holdRandom;
}
}//At the end of this for loop;each row will be loaded by different number and they&裟re not same
}
else
&褳
hold[i][0]=index;
int []hold_hold=new int[9];
for(int j=1;j<=9;j++)
&褳
int holdRandom=1+(int)(Math.random()*10);//It creates random number between 1 and 10; one and nine included
while(holdRandom==index)
&褳
holdRandom=1+(int)(Math.random()*10);
}
if(ArrayCheck(hold_hold,holdRandom,j))
&褳
hold_hold[j]=holdRandom;
}
}//At the end of this for loop;each row will be loaded by different number and they&裟re not same
if(CheckTheOtherRows(hold,hold_hold,i-1))
&褳
for(int k=0;k<=9;k++)
hold[i][k]==hold_hold[k];
}
}
}
return hold[i];
}
public void CheckTheOtherRows(int[}[]hold,int []hold_hold,int bigRow)
&褳
for(int i=0;i<=bigRow;i++)
&褳
if(ArrayToString(hold[i])== ArrayToString(hold_hold))
return false;
}
return true;
}
public String ArrayToString(int[]array)
&褳
String str="";
for (int i = 0; i < array.length; i++)
str = str + stringarray[i];
return str;
}
public boolean ArrayCheck(int []number,int random,int j)//DUZELTİLECEK
&褳
int newRandom;
if(NotInTheArray(number,random,j))
&褳
return true;
}
else
&褳
while( !NotInTheArray(number,random,j))//Send only the row
&褳
newRandom=1+(int)(Math.random()*10);
ArrayCheck(number,newRandom,j);//There is a recursion
}
continue;
}
}
public boolean NotInTheArray(int []hold,int check,int checkedIndex)
&褳
if(checkedIndex==1)
return true;
else
&褳
for(int i=1;i<checkedIndex;i++)
&褳
if(hold[i]== check)
return false;
}
}
return true;
}
public int SmallestCost(int[][]array,int[][]table)
&褳
int sum =0;
for(int row=0;row<factorial(9);row++)
&褳
for(int column=0;column<=9;column++)
&褳
}
}
}
}
Bu konu atacker tarafından düzenlendi(2008-05-14 20:25, 17 yıl önce)