2021-10-21 12:30:17 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "vec.cpp"
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
int flag = 0;
|
|
|
|
|
int temp[5];
|
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
clock_t astart_t, aend_t, a_start_t, a_end_t;
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
clock_t bstart_t, bend_t, b_start_t, b_end_t;
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
|
|
|
|
srand(time(NULL));
|
|
|
|
|
int len;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
scanf("%d", &len);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
// scanf("%d", &len);
|
2021-10-28 12:48:14 +00:00
|
|
|
|
Vec a(len, 1);
|
|
|
|
|
Vec b(len, 2);
|
|
|
|
|
Vec a_(&a);
|
|
|
|
|
Vec b_(&b);
|
|
|
|
|
printf("A<EFBFBD>鲢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...\n");
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
astart_t = clock();
|
|
|
|
|
a.mergeSort(0, a.getused());
|
|
|
|
|
aend_t = clock();
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
printf("Að<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...\n");
|
|
|
|
|
a_start_t = clock();
|
|
|
|
|
a_.bubbleSort();
|
|
|
|
|
a_end_t = clock();
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
printf("B<EFBFBD>鲢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...\n");
|
|
|
|
|
bstart_t = clock();
|
|
|
|
|
b.mergeSort(0, a.getused());
|
|
|
|
|
bend_t = clock();
|
|
|
|
|
|
|
|
|
|
printf("Bð<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...\n");
|
|
|
|
|
b_start_t = clock();
|
|
|
|
|
b_.bubbleSort();
|
|
|
|
|
b_end_t = clock();
|
|
|
|
|
|
|
|
|
|
printf("A<EFBFBD>鲢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>: %.4f <20><>\n", ((double)(aend_t - astart_t) / CLOCKS_PER_SEC));
|
|
|
|
|
printf("Að<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>: %.4f <20><>\n", ((double)(a_end_t - a_start_t) / CLOCKS_PER_SEC));
|
|
|
|
|
printf("B<EFBFBD>鲢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>: %.4f <20><>\n", ((double)(bend_t - bstart_t) / CLOCKS_PER_SEC));
|
|
|
|
|
printf("Bð<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>: %.4f <20><>\n", ((double)(b_end_t - b_start_t) / CLOCKS_PER_SEC));
|
|
|
|
|
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鲢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A:\n[0-19]\n");
|
|
|
|
|
for (int i = 0; i <= 19; i++)
|
|
|
|
|
printf("%d\n", a_.get(i));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
printf("[50000-50019]\n");
|
2021-10-28 12:48:14 +00:00
|
|
|
|
for (int i = 50000; i <= 50019; i++)
|
|
|
|
|
printf("%d\n", a_.get(i));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
printf("[99980-99999]\n");
|
2021-10-28 12:48:14 +00:00
|
|
|
|
for (int i = 99980; i <= 99999; i++)
|
|
|
|
|
printf("%d\n", a_.get(i));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鲢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B:\n[0-19]\n");
|
|
|
|
|
for (int i = 0; i <= 19; i++)
|
|
|
|
|
printf("%d\n", b.get(i));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
printf("[50000-50019]\n");
|
2021-10-28 12:48:14 +00:00
|
|
|
|
for (int i = 50000; i <= 50019; i++)
|
|
|
|
|
printf("%d\n", b.get(i));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
printf("[99980-99999]\n");
|
2021-10-28 12:48:14 +00:00
|
|
|
|
for (int i = 99980; i <= 99999; i++)
|
|
|
|
|
printf("%d\n", b.get(i));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
2021-10-28 12:48:14 +00:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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));
|
2021-10-21 12:30:17 +00:00
|
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|