Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SumSumTask
- {
- using System;
- using System.Collections.Generic;
- public class TwoSum
- {
- public int SumOfTwoSumTargets (int[] numbers, int min, int max)
- {
- int target = 0;
- int sum = 0;
- int num1 = 0;
- int num2 = 0;
- List<int> sums = new List<int>();
- int sumOfNums = 0;
- for(int x = min;x < max;x++)
- {
- target = x;
- for(int y = 0;y < numbers.Length;y++)
- {
- num1 = numbers[y];
- num2 = target - num1;
- sum = num1 + num2;
- }
- if(sum == target)
- {
- sums.Add(sum);
- }
- }
- for(int i = 0;i < sums.Count;i++)
- {
- sumOfNums += sums[i];
- }
- return sumOfNums;
- }
- }
- }
Add Comment
Please, Sign In to add comment