文件归档移动

This commit is contained in:
iridiumR 2022-02-10 16:09:15 +08:00
parent d99cafc5d0
commit 319ed1d8e2
11 changed files with 26 additions and 22 deletions

BIN
DataStructure/Code.7z Normal file

Binary file not shown.

View file

@ -12,41 +12,41 @@ int main()
srand(time(NULL)); srand(time(NULL));
int len; int len;
printf("输入秩\n"); printf("输入秩\n");
scanf("%d", &len); scanf("%d", &len);
printf("生成数组\n"); printf("生成数组\n");
// scanf("%d", &len); // scanf("%d", &len);
Vec a(len, 1); Vec a(len, 1);
Vec b(len, 2); Vec b(len, 2);
Vec a_(&a); Vec a_(&a);
Vec b_(&b); Vec b_(&b);
printf("A归并排序...\n"); printf("A归并排序...\n");
astart_t = clock(); astart_t = clock();
a.mergeSort(0, a.getused()); a.mergeSort(0, a.getused());
aend_t = clock(); aend_t = clock();
printf("A冒泡排序...\n"); printf("A冒泡排序...\n");
a_start_t = clock(); a_start_t = clock();
a_.bubbleSort(); a_.bubbleSort();
a_end_t = clock(); a_end_t = clock();
printf("B归并排序...\n"); printf("B归并排序...\n");
bstart_t = clock(); bstart_t = clock();
b.mergeSort(0, a.getused()); b.mergeSort(0, a.getused());
bend_t = clock(); bend_t = clock();
printf("B冒泡排序...\n"); printf("B冒泡排序...\n");
b_start_t = clock(); b_start_t = clock();
b_.bubbleSort(); b_.bubbleSort();
b_end_t = clock(); b_end_t = clock();
printf("A归并运算时间: %.4f 秒\n", ((double)(aend_t - astart_t) / CLOCKS_PER_SEC)); 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("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)(bend_t - bstart_t) / CLOCKS_PER_SEC));
printf("B冒泡运算时间: %.4f 秒\n", ((double)(b_end_t - b_start_t) / CLOCKS_PER_SEC)); printf("B冒泡运算时间: %.4f 秒\n", ((double)(b_end_t - b_start_t) / CLOCKS_PER_SEC));
printf("输出归并样本A:\n[0-19]\n"); printf("输出归并样本A:\n[0-19]\n");
for (int i = 0; i <= 19; i++) for (int i = 0; i <= 19; i++)
printf("%d\n", a.get(i)); printf("%d\n", a.get(i));
printf("[50000-50019]\n"); printf("[50000-50019]\n");
@ -56,7 +56,7 @@ int main()
for (int i = 99980; i <= 99999; i++) for (int i = 99980; i <= 99999; i++)
printf("%d\n", a.get(i)); printf("%d\n", a.get(i));
printf("输出冒泡样本A:\n[0-19]\n"); printf("输出冒泡样本A:\n[0-19]\n");
for (int i = 0; i <= 19; i++) for (int i = 0; i <= 19; i++)
printf("%d\n", a_.get(i)); printf("%d\n", a_.get(i));
printf("[50000-50019]\n"); printf("[50000-50019]\n");
@ -66,7 +66,7 @@ int main()
for (int i = 99980; i <= 99999; i++) for (int i = 99980; i <= 99999; i++)
printf("%d\n", a_.get(i)); printf("%d\n", a_.get(i));
printf("输出归并样本B:\n[0-19]\n"); printf("输出归并样本B:\n[0-19]\n");
for (int i = 0; i <= 19; i++) for (int i = 0; i <= 19; i++)
printf("%d\n", b.get(i)); printf("%d\n", b.get(i));
printf("[50000-50019]\n"); printf("[50000-50019]\n");
@ -76,7 +76,7 @@ int main()
for (int i = 99980; i <= 99999; i++) for (int i = 99980; i <= 99999; i++)
printf("%d\n", b.get(i)); printf("%d\n", b.get(i));
printf("输出冒泡样本B:\n[0-19]\n"); printf("输出冒泡样本B:\n[0-19]\n");
for (int i = 0; i <= 19; i++) for (int i = 0; i <= 19; i++)
printf("%d\n", b_.get(i)); printf("%d\n", b_.get(i));
printf("[50000-50019]\n"); printf("[50000-50019]\n");

View file

@ -66,7 +66,7 @@ void Vec::shrink()
delete[] _v; delete[] _v;
_v = p; _v = p;
} }
//位置 数值 //位置 数值
int Vec::insert(int locate, int value) int Vec::insert(int locate, int value)
{ {
if (locate == _used + 1) if (locate == _used + 1)
@ -91,7 +91,7 @@ int Vec::insert(int locate, int value)
return 0; return 0;
} }
//位置 删除个数 //位置 删除个数
int Vec::remove(int locate, int value) int Vec::remove(int locate, int value)
{ {
@ -108,7 +108,7 @@ int Vec::remove(int locate, int value)
return value; return value;
} }
//删除某一元素 //删除某一元素
int Vec::remove_sorted(int value) int Vec::remove_sorted(int value)
{ {
int j, i; int j, i;

View file

@ -68,7 +68,7 @@ void Vec::shrink()
delete[] _v; delete[] _v;
_v = p; _v = p;
} }
//位置 数值 //位置 数值
int Vec::insert(int locate, int value) int Vec::insert(int locate, int value)
{ {
if (locate == _used + 1) if (locate == _used + 1)
@ -93,7 +93,7 @@ int Vec::insert(int locate, int value)
return 0; return 0;
} }
//位置 删除个数 //位置 删除个数
int Vec::remove(int locate, int value) int Vec::remove(int locate, int value)
{ {
@ -110,7 +110,7 @@ int Vec::remove(int locate, int value)
return value; return value;
} }
//删除某一元素 //删除某一元素
int Vec::remove_sorted(int value) int Vec::remove_sorted(int value)
{ {
int j, i; int j, i;

4
DataStructure/README.md Normal file
View file

@ -0,0 +1,4 @@
# 数据结构与算法设计 课程作业
使用`gcc/clang`编译,部分配置文件可见[此处](https://irr.ink/2021/1XJKHTE/)。

View file

@ -47,6 +47,7 @@
"typeinfo": "cpp", "typeinfo": "cpp",
"ctime": "cpp", "ctime": "cpp",
"iomanip": "cpp" "iomanip": "cpp"
} },
"commentTranslate.hover.enabled": true
} }
} }

View file

@ -1 +0,0 @@
# 数据结构与算法设计 课程作业