文件归档移动
This commit is contained in:
parent
d99cafc5d0
commit
319ed1d8e2
11 changed files with 26 additions and 22 deletions
BIN
DataStructure/Code.7z
Normal file
BIN
DataStructure/Code.7z
Normal file
Binary file not shown.
|
@ -12,41 +12,41 @@ int main()
|
|||
|
||||
srand(time(NULL));
|
||||
int len;
|
||||
printf("输入秩\n");
|
||||
printf("输入秩\n");
|
||||
scanf("%d", &len);
|
||||
printf("生成数组\n");
|
||||
printf("生成数组\n");
|
||||
// scanf("%d", &len);
|
||||
Vec a(len, 1);
|
||||
Vec b(len, 2);
|
||||
Vec a_(&a);
|
||||
Vec b_(&b);
|
||||
printf("A归并排序...\n");
|
||||
printf("A归并排序...\n");
|
||||
|
||||
astart_t = clock();
|
||||
a.mergeSort(0, a.getused());
|
||||
aend_t = clock();
|
||||
|
||||
printf("A冒泡排序...\n");
|
||||
printf("A冒泡排序...\n");
|
||||
a_start_t = clock();
|
||||
a_.bubbleSort();
|
||||
a_end_t = clock();
|
||||
|
||||
printf("B归并排序...\n");
|
||||
printf("B归并排序...\n");
|
||||
bstart_t = clock();
|
||||
b.mergeSort(0, a.getused());
|
||||
bend_t = clock();
|
||||
|
||||
printf("B冒泡排序...\n");
|
||||
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归并运算时间: %.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");
|
||||
printf("输出归并样本A:\n[0-19]\n");
|
||||
for (int i = 0; i <= 19; i++)
|
||||
printf("%d\n", a.get(i));
|
||||
printf("[50000-50019]\n");
|
||||
|
@ -56,7 +56,7 @@ int main()
|
|||
for (int i = 99980; i <= 99999; 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++)
|
||||
printf("%d\n", a_.get(i));
|
||||
printf("[50000-50019]\n");
|
||||
|
@ -66,7 +66,7 @@ int main()
|
|||
for (int i = 99980; i <= 99999; 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++)
|
||||
printf("%d\n", b.get(i));
|
||||
printf("[50000-50019]\n");
|
||||
|
@ -76,7 +76,7 @@ int main()
|
|||
for (int i = 99980; i <= 99999; 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++)
|
||||
printf("%d\n", b_.get(i));
|
||||
printf("[50000-50019]\n");
|
||||
|
|
|
@ -66,7 +66,7 @@ void Vec::shrink()
|
|||
delete[] _v;
|
||||
_v = p;
|
||||
}
|
||||
//位置 数值
|
||||
//位置 数值
|
||||
int Vec::insert(int locate, int value)
|
||||
{
|
||||
if (locate == _used + 1)
|
||||
|
@ -91,7 +91,7 @@ int Vec::insert(int locate, int value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//位置 删除个数
|
||||
//位置 删除个数
|
||||
int Vec::remove(int locate, int value)
|
||||
{
|
||||
|
||||
|
@ -108,7 +108,7 @@ int Vec::remove(int locate, int value)
|
|||
return value;
|
||||
}
|
||||
|
||||
//删除某一元素
|
||||
//删除某一元素
|
||||
int Vec::remove_sorted(int value)
|
||||
{
|
||||
int j, i;
|
||||
|
|
|
@ -68,7 +68,7 @@ void Vec::shrink()
|
|||
delete[] _v;
|
||||
_v = p;
|
||||
}
|
||||
//位置 数值
|
||||
//位置 数值
|
||||
int Vec::insert(int locate, int value)
|
||||
{
|
||||
if (locate == _used + 1)
|
||||
|
@ -93,7 +93,7 @@ int Vec::insert(int locate, int value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//位置 删除个数
|
||||
//位置 删除个数
|
||||
int Vec::remove(int locate, int value)
|
||||
{
|
||||
|
||||
|
@ -110,7 +110,7 @@ int Vec::remove(int locate, int value)
|
|||
return value;
|
||||
}
|
||||
|
||||
//删除某一元素
|
||||
//删除某一元素
|
||||
int Vec::remove_sorted(int value)
|
||||
{
|
||||
int j, i;
|
||||
|
|
4
DataStructure/README.md
Normal file
4
DataStructure/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# 数据结构与算法设计 课程作业
|
||||
|
||||
使用`gcc/clang`编译,部分配置文件可见[此处](https://irr.ink/2021/1XJKHTE/)。
|
||||
|
|
@ -47,6 +47,7 @@
|
|||
"typeinfo": "cpp",
|
||||
"ctime": "cpp",
|
||||
"iomanip": "cpp"
|
||||
}
|
||||
},
|
||||
"commentTranslate.hover.enabled": true
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
# 数据结构与算法设计 课程作业
|
Reference in a new issue