diff options
| author | Steve Lee <me@xiangyangli.com> | 2017-10-17 00:12:32 +0800 |
|---|---|---|
| committer | Steve Lee <me@xiangyangli.com> | 2017-10-17 00:12:32 +0800 |
| commit | b46c49228497cb440467167bad3123c327bd620f (patch) | |
| tree | 7547f4da0694b7c85e57e7e56cd1f0e6f3cdc4d8 /leetcode | |
| parent | 37f4cc25e5bcf68539d2b3828ecff5d72ae8c74b (diff) | |
| download | 42-b46c49228497cb440467167bad3123c327bd620f.tar.xz 42-b46c49228497cb440467167bad3123c327bd620f.zip | |
add
Diffstat (limited to 'leetcode')
| -rw-r--r-- | leetcode/1_two_sum.c | 26 | ||||
| -rwxr-xr-x | leetcode/a.out | bin | 0 -> 7104 bytes |
2 files changed, 26 insertions, 0 deletions
diff --git a/leetcode/1_two_sum.c b/leetcode/1_two_sum.c new file mode 100644 index 0000000..fe29ecc --- /dev/null +++ b/leetcode/1_two_sum.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +int result[2]; + +int* two_sum(int* nums, int nums_size, int target) +{ + int i, j; + for(i = 0; i < nums_size; i++) + for(j = 0; j < nums_size; j++) + if(nums[i] + nums[j] == target) { + printf("%d+%d = %d\n", nums[i], nums[j], target); + result[0] = i; + result[1] = j; + return result; + } + +} + +int main() +{ + int nums[4] = {2, 7, 11, 15}; + two_sum(nums, 4, 9); + printf("%d, %d\n",result[0], result[1]); + + return 0; +} diff --git a/leetcode/a.out b/leetcode/a.out Binary files differnew file mode 100755 index 0000000..0aa8167 --- /dev/null +++ b/leetcode/a.out |
