int main () { int *a; int f; int i; f=n; // printf("Input the number of numbers\n"); // scanf("\n%d", &n); a=(int *)malloc(n*sizeof(int)); // printf("Choose how to full unsorted massive: 1 - rand,2 - best,3 - worst\n"); // scanf("%d",&i); switch(v) { case 1: randInput(a); break; case 2: bestInput(a); break; case 3: worstInput(a); break; default: exit(EXIT_FAILURE); } //int n = sizeof a / sizeof a[0]; for (i = 0; i < n; i++) { printf("%d%s", a[i], i%20 == 0 ? "\n" : " ");} QuickSort(a,f); for (i = 0; i < n; i++) { printf("%d%s", a[i], i%20 == 0 ? "\n" : " ");} printf("\nKol-vo perestanovok i sravneniy: %d, %d",q,s); return 0; }
/****************************************************************************** * Execution of program begins from here * ******************************************************************************/ int main(int argc, char * argv[]) { std::cout << "**********************************************" << std::endl; std::cout << "Introducing sort in BOLT" << std::endl; std::cout << "**********************************************" << std::endl; /************************************************************************** * bolt::cl::sort usage with basic vector type. * * The parameter list of sort() in bolt::cl namespace is similar to the * * parameter list of std::sort(), infact bolt::cl can be replaced with * * std:: in the following code * **************************************************************************/ std::vector<int> randInput(INPUT_SIZE_50); std::generate(randInput.begin(), randInput.end(), rand); bolt::cl::sort(randInput.begin(), randInput.end(), bolt::cl::less<int>()); printArray("Ascending vector 50 values", randInput.data(), INPUT_SIZE_50); bolt::cl::sort(randInput.begin(), randInput.end(), bolt::cl::greater<int>()); printArray("Descending vector 50 values", randInput.data(), INPUT_SIZE_50); /************************************************************************** * bolt::cl::sort usage with Array type * **************************************************************************/ int arrInp[INPUT_SIZE_10] = {2, 9, 3, 7, 5, 6, 3, 8, 10, 1}; bolt::cl::sort(arrInp, arrInp+INPUT_SIZE_10, bolt::cl::greater<int>()); printArray("Descending array 10 values", arrInp, INPUT_SIZE_10); std::cout << std::endl; return 0; }