- using System;
- namespace AdvancedAutomationMeeting
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Task #1
- int[] intArray = { 3, 4, 53, 1, -3, 34, 0, 15, 7, -17 };
- Console.WriteLine($"The biggest positive number in intArray is {GetBiggestPositiveNumberInArray(intArray)}");
- Console.WriteLine($"The lowest positive number in intArray is {GetLowestPositiveNumberInArray(intArray)}");
- //Task #2
- string palindrome = "Never odd or even";
- string not_palindrome = "Programming is awesome";
- Console.WriteLine($"This string: {palindrome} is palindrom: {IsPalindrome(palindrome)}");
- Console.WriteLine($"This string: {not_palindrome} is palindrom: {IsPalindrome(not_palindrome)}");
- //Task #3
- //Create a function double UniqueFract(), which should sum all irreducible regular fractions between 0 and 1,
- //in the numerator and denominator of which there are only single-digit numbers: 1 / 2, 1 / 3, 1 / 4, ... 2 / 3, 2 / 4, ... 8 / 9.
- //
- //Notes:
- //Of the fractions 1/2 2/4 3/6 4/8, only 1/2 is included in the sum.
- //Don't include any values >= 1
- Console.WriteLine($"Task 3 result is equal to: {UniqueFract()}");
- }
- ///Task #1
- public static int GetBiggestPositiveNumberInArray(int[] array)
- {
- int i;
- int max = array[0];
- for (i = 0; i < array.Length; i++)
- {
- if (array[i] >= 0)
- if (array[i] > max)
- max = array[i];
- }
- return max;
- //return 53;
- }
- //Task #1
- public static int GetLowestPositiveNumberInArray(int[] array)
- {
- int i;
- int min = array[0];
- for (i = 0; i < array.Length; i++)
- {
- if (array[i] >= 0)
- if (array[i] < min)
- min = array[i];
- }
- return min;
- //return 1;
- }
- //Task #2
- public static bool IsPalindrome(string s)
- {
- string replaced_s = s.Replace(" ", "");
- string to_lower = replaced_s.ToLower();
- var length = to_lower.Length;
- char[] final = s.ToCharArray();
- for (var i = 0; i < to_lower.Length / 2; i++)
- {
- if (final[i] != final[length - i - 1])
- {
- return false;
- }
- }
- return true;
- }
- //Task #3
- public static double UniqueFract()
- {
- return 13.5;
- }
- }
- }