Ver Fonte

上传文件至 '随机数排序C++'

lisihan há 6 meses atrás
pai
commit
cf9d8fa5ac
3 ficheiros alterados com 14 adições e 21 exclusões
  1. 1 15
      随机数排序C++/algo.cpp
  2. 2 4
      随机数排序C++/io.h
  3. 11 2
      随机数排序C++/main.cpp

+ 1 - 15
随机数排序C++/algo.cpp

@@ -43,18 +43,4 @@ void swap(int* arr, int left, int right)
     temp = arr[right];
     arr[right] = arr[left];
     arr[left] = temp;
-}
-
-
-int* RandomArrayCreate(int Arraylength)
-{
-    int static arr[10];
-
-    srand((unsigned int)time(NULL));
-    for (int i = 0; i < Arraylength; i++)
-    {
-        arr[i] = 1 + rand() % 100;
-    }
-
-    return arr;
-}
+}

+ 2 - 4
随机数排序C++/io.h

@@ -1,9 +1,8 @@
 #pragma once
 #include<iostream>
-#ifndef IO_H
-#define IO_H
+//用于输出数组的函数声明
 void OutPut(int* arr/*I*/, int Arraylength/*I*/);
-
+//用于输入数组长度的函数声明
 void InPutArrayLength(int *Arraylength/*O*/);
 
 //05/23/2024 Li SiHan Added Start
@@ -25,4 +24,3 @@ void foreach(ObjectTraversed  obj, int Arraylength)
     }
 }
 //05/23/2024 Li SiHan Added End
-#endif  

+ 11 - 2
随机数排序C++/main.cpp

@@ -13,12 +13,17 @@
  05/19/2024         Li SiHan         Created
  05/21/2024         Li SiHan         Added Code comments and Assert function
  05/23/2024         Li SiHan         Change C to C++ and Added OutPut Template function and Code comments
+ 05/27/2024         Li SiHan         Added Code comments and dll
  $HISTORY$
  ================================================================================
  */
 #include<stdio.h>
 #include"algo.h"
 #include"io.h"
+//05/27/2024 Li SiHan Added Start
+//动态链接库的头文件引用
+#include"GenerateMethod.h"
+//05/27/2024 Li SiHan Added End
 int main()
 {
     //对于数组的长度这一变量进行声明及初始化
@@ -26,9 +31,12 @@ int main()
 
     //用户对数组长度这一变量进行赋值
     InPutArrayLength(&Arraylength); 
-   
-    //生成并返回所需长度的随机数组
+
+    //05/27/2024 Li SiHan Added Start
+    //用动态链接库的方法生成并返回所需长度的随机数组
     int* arr = RandomArrayCreate(Arraylength); 
+    //05/27/2024 Li SiHan Added End
+
     //输出当前所生成的数组
     OutPut(arr,Arraylength); 
 
@@ -41,6 +49,7 @@ int main()
     //05/23/2024 Li SiHan Added End
 
     return 0;
+ 
 }