Ver código fonte

上传文件至 ''

lisihan 6 meses atrás
pai
commit
5e06398ed3
2 arquivos alterados com 30 adições e 0 exclusões
  1. 20 0
      GenerateMethod.cpp
  2. 10 0
      GenerateMethod.h

+ 20 - 0
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
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