#通过两个循环遍历数组中的所有配对,查看求和结果是否和目标相等
##代码如下
public class Solution
{
public int[] TwoSum(int[] nums, int target)
{
int[] result = new int[2];
for (int i = 0; i < nums.Length - 1; i++)
{
for (int j = i + 1; j < nums.Length; j++)
{
if (nums[i] + nums[j] == target)
{
result[0] = i;
result[1] = j;
return result;
}
}
}
return null;
}
}