Browse Source

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

lisihan 4 tháng trước cách đây
mục cha
commit
ce498e3cc8
2 tập tin đã thay đổi với 30 bổ sung0 xóa
  1. 20 0
      随机数排序C++/GenerateMethod.cpp
  2. 10 0
      随机数排序C++/GenerateMethod.h

+ 20 - 0
随机数排序C++/GenerateMethod.cpp

@@ -0,0 +1,20 @@
+//05/27/2024 Li SiHan Added Start
+#include"pch.h"
+#include "GenerateMethod.h"
+//随机数生成所需要引用的包
+#include<stdlib.h>
+#include<time.h>
+
+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;
+}
+//05/27/2024 Li SiHan Added End

+ 10 - 0
随机数排序C++/GenerateMethod.h

@@ -0,0 +1,10 @@
+//05/27/2024 Li SiHan Added Start
+//动态链接库的头文件
+#pragma once  //规定只编译一次
+
+//宏定义,增加可读性
+#define DATAEXCHANGEDLL_API __declspec(dllexport)
+
+//按C进行编译,声明.cpp中的函数
+extern "C" DATAEXCHANGEDLL_API int* RandomArrayCreate(int Arraylength/*I*/);
+//05/27/2024 Li SiHan Added End