Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("ANSWER --- Output Value: {0}", lowPosNotIn(new int[] { 1, 3, 6, 4, 1, 2 }));
- Console.WriteLine("ANSWER --- Output Value: {0}", lowPosNotIn(new int[] { 1, 2, 3 }));
- Console.WriteLine("ANSWER --- Output Value: {0}", lowPosNotIn(new int[] { -1, -3 }));
- Console.WriteLine("ANSWER --- Output Value: {0}", lowPosNotIn(new int[] { 1, -8, 3, 888, 6, -4, 1, 2, 3, 4, 5, 7, 8, 9, 10, 1024, 65536, 1 }));
- Console.ReadLine();
- }
- private static int lowPosNotIn(int[] arrIN)
- {
- Array.Sort(arrIN);
- int lowPositive = 1;
- foreach(int i in arrIN)
- {
- if (((i > lowPositive || lowPositive > i) != true) && (i>0))
- {
- lowPositive++;
- }
- }
- return lowPositive;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement