Beispiel #1
0
 int main ()
 {
     int n, i;
     int *a;
     printf("Please insert the number of elements to be sorted: ");
     scanf("%d", &n);       // The total number of elements
     a  =  (int *)calloc(n, sizeof(int));
     for (i = 0;i< n;i++)
     {
         printf("Input element %d :", i);
         scanf("%d", &a[i]); // Adding the elements to the array
     }
     printf("unsorted list");       // Displaying the unsorted array
     for(i = 0;i < n;i++)
     {
          printf("%d", a[i]);
     }
     combsort(a, n);
     printf("Sorted list:\n");        // Display the sorted array
     for(i = 0;i < n;i++)
     {
         printf("%d ", (a[i]));
     }
     return 0;
 }
int main() {

    int vec[ SIZE ], 

        n, 

        i;

    freopen(FIN, "r", stdin);

    freopen(FOUT, "w", stdout);

    scanf("%d", &n);

    for(i = 0; i < n; ++i) scanf("%d", &vec[i]);

    combsort(vec, n); 

    for(i = 0; i < n; ++i) printf("%d ", vec[i]);
 
 return(0);
};
Beispiel #3
0
/*
 * Главная функция
 * */
int main()
{
    // Пути к входным/выходным файлам
    const char * infileName = "H:\\input.txt";
    const char * outfileName1 = "H:\\output1.txt";
    const char * outfileName2 = "H:\\output2.txt";
    const char * outfileName3 = "H:\\output3.txt";
    std::cout << "Hello World!" << std::endl; // Приветственное слово
    std::vector <sort_type> data; // хранилище данных
    std::cout << "qSort" << std::endl;
    read(data, infileName);
    qSort(data); // Быстрая сортировка
    write(data, outfileName1);
    std::cout << "sortBubble" << std::endl;
    read(data, infileName);
    sortBubble( data); // Сортировка пузырьком
    write(data, outfileName2);
    std::cout << "combsort" << std::endl;
    read(data, infileName);
    combsort( data); // Сортировка расчёсткой
    write(data, outfileName3);
    return 0;
}