/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* twoSum(int* nums, int numsSize, int target, int* returnSize){
int *indi = NULL;
indi = (int *)malloc(2 * sizeof(int));
int temp[numsSize],i,j;
for(i=0;i<numsSize;i++)
{
temp[i] = target - nums[i];
for(j=i+1;j<numsSize;j++)
{
if(temp[i]==nums[j])
{
indi[0] = i;
indi[1] = j;
* returnSize=2;
return indi;
}
}
}
* returnSize=0;
return indi;
}
运行一般,后期学的好一点再优化。