|
|
вернуться в форумRe: what is the algorithm :? the algorithm consist of transposition the most high soldier to the centre of the line and to the centre of the column. in cycle from 1 to n gives bubble sorting. Re: what is the algorithm :? Послано melkiy 11 мар 2009 07:05 Please can you explain how to do bubble sort in 2-d array here? algorithm Послано melkiy 11 мар 2009 07:14 I constructed such an algorithm. It requires the soldiers to be sorted by their height downwards. When the soldiers are sorted, take them one by one and fill the square diamond by diamond, starting from center. A "diamond" contains those cells (x,y) for which |x - x_center| + |y - y_center| == C, C ranges [0; n-1]. Edited by author 11.03.2009 08:54 Re: algorithm it's no solution Re: algorithm There is a much simpler method, which also uses less memory. Hint: try a O(n) sort. Also try not to store n*n elements in memory (print line by line instead). |
|
|