From Crippled Sheep, 5 Years ago, written in Plain Text.
Embed
  1. using System;
  2.  
  3. namespace AdvancedAutomationMeeting
  4. {
  5.         class Program
  6.         {
  7.                 static void Main(string[] args)
  8.                 {
  9.                         //Task #1
  10.                         int[] intArray = { 3, 4, 53, 1, -3, 34, 0, 15, 7, -17 };
  11.  
  12.                         Console.WriteLine($"The biggest positive number in intArray is {GetBiggestPositiveNumberInArray(intArray)}");
  13.                         Console.WriteLine($"The lowest positive number in intArray is {GetLowestPositiveNumberInArray(intArray)}");
  14.  
  15.                         //Task #2
  16.                         string palindrome = "Never odd or even";
  17.                         string not_palindrome = "Programming is awesome";
  18.  
  19.                         Console.WriteLine($"This string: {palindrome} is palindrom: {IsPalindrome(palindrome)}");
  20.                         Console.WriteLine($"This string: {not_palindrome} is palindrom: {IsPalindrome(not_palindrome)}");
  21.  
  22.                         //Task #3
  23.                         //Create a function double UniqueFract(), which should sum all irreducible regular fractions between 0 and 1,
  24.                         //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.
  25.                         //
  26.                         //Notes:
  27.                         //Of the fractions 1/2 2/4 3/6 4/8, only 1/2 is included in the sum.
  28.                         //Don't include any values >= 1
  29.                         Console.WriteLine($"Task 3 result is equal to: {UniqueFract()}");
  30.                 }
  31.  
  32.                 ///Task #1
  33.                 public static int GetBiggestPositiveNumberInArray(int[] array)
  34.                 {
  35.                         int i;
  36.                         int max = array[0];
  37.                         for (i = 0; i < array.Length; i++)
  38.                                 {
  39.                                 if (array[i] >= 0)
  40.                                         if (array[i] > max)
  41.                                         max = array[i];
  42.                                 }
  43.                         return max;
  44.  
  45.  
  46.  
  47.  
  48.                         //return 53;
  49.                 }
  50.  
  51.                 //Task #1
  52.                 public static int GetLowestPositiveNumberInArray(int[] array)
  53.                 {
  54.                         int i;
  55.                         int min = array[0];
  56.                         for (i = 0; i < array.Length; i++)
  57.                                 {
  58.                                 if (array[i] >= 0)
  59.                                         if (array[i] < min)
  60.                                                 min = array[i];
  61.                                 }
  62.                         return min;
  63.                         //return 1;
  64.                 }
  65.  
  66.                 //Task #2
  67.                 public static bool IsPalindrome(string s)
  68.                 {
  69.                         string replaced_s = s.Replace(" ", "");
  70.                         string to_lower = replaced_s.ToLower();
  71.                         var length = to_lower.Length;
  72.                         char[] final = s.ToCharArray();
  73.  
  74.  
  75.                         for (var i = 0; i < to_lower.Length / 2; i++)
  76.                         {
  77.                                 if (final[i] != final[length - i - 1])
  78.                                 {
  79.                                         return false;
  80.                                 }
  81.                         }
  82.                         return true;
  83.  
  84.                 }
  85.                         //Task #3
  86.                         public static double UniqueFract()
  87.                 {
  88.                         return 13.5;
  89.                 }
  90.         }
  91. }
  92.