void main() { int *a, n; srand(time(0)); // Khởi tạo giá trị ngẫu nhiên input(a, n); output(a, n); printf("Mang sau khi sap xep: \n"); shakerSort(a, n); output(a, n); }
void ParticleCollection::sortParticles(int particles) { numParticles = particles; // How many of the particles we are sorting. int xStart = 0; // The index of the start of the current x-values. int yStart = 0; // The index of the start of the current y-values. int xEnd = 0; // The index of the end of the current x-values. int yEnd = 0; // The index of the end of the current y-values. for(int x = 0; x < xSize; x++) { xEnd = carlSort(x, xStart); // carlSort will return the last index of the current x-values. for(int y = 0; y < ySize; y++) { yEnd = carlYSort(y, yStart, xEnd); // carlYSort will return the last index of the current y-values. shakerSort(yStart, yEnd); // shaker sort will sort the z-values at the given x,y values. yStart = yEnd; } xStart = xEnd; } }