sexecutora

Untitled

May 5th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _04.ArrayCoincedence
  7. {
  8. class ArrayCoincedence
  9. {
  10.  
  11. static void Array_Coincedence(int[] array)
  12. {
  13. int count = 0;
  14. int coincedence = 0;
  15.  
  16. for (int index = 0; index < array.Length; index++)
  17. {
  18. try
  19. {
  20. if (array[index] == array[index + 1])
  21. {
  22. coincedence = array[index];
  23.  
  24. break;
  25. }
  26. }
  27. catch (Exception)
  28. {
  29. }
  30.  
  31. }
  32.  
  33. foreach (var numbers in array)
  34. {
  35. if (numbers == coincedence)
  36. {
  37. count++;
  38. }
  39. }
  40.  
  41. Console.WriteLine(count);
  42.  
  43. }
  44.  
  45. static void Main(string[] args)
  46. {
  47.  
  48. int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  49.  
  50. Array_Coincedence(n);
  51.  
  52. }
  53. }
  54. }
Add Comment
Please, Sign In to add comment