#include <stdio.h>
#include <stdlib.h>
#include "vec.h"
int main()
{
    int flag = 0;
    int temp[5];

    clock_t astart_t, aend_t, a_start_t, a_end_t;

    clock_t bstart_t, bend_t, b_start_t, b_end_t;

    srand(time(NULL));
    int len;
    printf("输入秩\n");
    scanf("%d", &len);
    printf("生成数组\n");
    // scanf("%d", &len);
    Vec a(len, 1);
    Vec b(len, 2);
    Vec a_(&a);
    Vec b_(&b);
    printf("A归并排序...\n");

    astart_t = clock();
    a.mergeSort(0, a.getused());
    aend_t = clock();

    printf("A冒泡排序...\n");
    a_start_t = clock();
    a_.bubbleSort();
    a_end_t = clock();

    printf("B归并排序...\n");
    bstart_t = clock();
    b.mergeSort(0, a.getused());
    bend_t = clock();

    printf("B冒泡排序...\n");
    b_start_t = clock();
    b_.bubbleSort();
    b_end_t = clock();

    printf("A归并运算时间: %.4f 秒\n", ((double)(aend_t - astart_t) / CLOCKS_PER_SEC));
    printf("A冒泡运算时间: %.4f 秒\n", ((double)(a_end_t - a_start_t) / CLOCKS_PER_SEC));
    printf("B归并运算时间: %.4f 秒\n", ((double)(bend_t - bstart_t) / CLOCKS_PER_SEC));
    printf("B冒泡运算时间: %.4f 秒\n", ((double)(b_end_t - b_start_t) / CLOCKS_PER_SEC));

    printf("输出归并样本A:\n[0-19]\n");
    for (int i = 0; i <= 19; i++)
        printf("%d\n", a.get(i));
    printf("[50000-50019]\n");
    for (int i = 50000; i <= 50019; i++)
        printf("%d\n", a.get(i));
    printf("[99980-99999]\n");
    for (int i = 99980; i <= 99999; i++)
        printf("%d\n", a.get(i));

    printf("输出冒泡样本A:\n[0-19]\n");
    for (int i = 0; i <= 19; i++)
        printf("%d\n", a_.get(i));
    printf("[50000-50019]\n");
    for (int i = 50000; i <= 50019; i++)
        printf("%d\n", a_.get(i));
    printf("[99980-99999]\n");
    for (int i = 99980; i <= 99999; i++)
        printf("%d\n", a_.get(i));

    printf("输出归并样本B:\n[0-19]\n");
    for (int i = 0; i <= 19; i++)
        printf("%d\n", b.get(i));
    printf("[50000-50019]\n");
    for (int i = 50000; i <= 50019; i++)
        printf("%d\n", b.get(i));
    printf("[99980-99999]\n");
    for (int i = 99980; i <= 99999; i++)
        printf("%d\n", b.get(i));

    printf("输出冒泡样本B:\n[0-19]\n");
    for (int i = 0; i <= 19; i++)
        printf("%d\n", b_.get(i));
    printf("[50000-50019]\n");
    for (int i = 50000; i <= 50019; i++)
        printf("%d\n", b_.get(i));
    printf("[99980-99999]\n");
    for (int i = 99980; i <= 99999; i++)
        printf("%d\n", b_.get(i));

    system("pause");
}
