diff --git "a/2209040033/chaper_1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" "b/2209040033/chaper_1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..4e7aa41400ae7a168241f99bc7ecf0642551b40a --- /dev/null +++ "b/2209040033/chaper_1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" @@ -0,0 +1,19 @@ +int* twoSum(int* nums, int numsSize, int target, int* returnSize) +{ + int * ret = NULL; + for (int i = 0; i < numsSize; ++i) + { + for (int j = i + 1; j < numsSize; ++j) + { + if (nums[i] + nums[j] == target) + { + int* ret = (int*)malloc(sizeof(int) * 2); + ret[0] = i, ret[1] = j; + *returnSize = 2; + return ret; + } + } + } + *returnSize = 0; + return NULL; +} \ No newline at end of file diff --git a/main.cpp b/main.cpp index 4562e17b782ed0a07d3274efd6e2cd31f395bce4..e76e3d83b6a276392d2870db08372016fa61cc5a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,22 @@ +<<<<<<< HEAD + class Solution { +public: + vector twoSum(vector& nums, int target) { + int i,j; + for(i=0;i int main(void) { @@ -5,3 +24,4 @@ int main(void) { return 0; } +>>>>>>> master