public static void Main() { int[] number={1,1,3,3,3,5,5,5,9,9,9,9}; int n = number.Length; for (int i = 0; i < n; i++) { if (number[i] != number[i + 1]) { Console.WriteLine(number[i]); } } }
Please correct me
public static void Main() { int[] number = { 1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9 }; int n = number.Length; for (int i = 0; i < n; i++) { if ((i + 1) < n && number[i] != number[i + 1]) { Console.WriteLine(number[i]); } } }
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.