Advertisement
Boris-Stavrev92

Untitled

Feb 26th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08_Increasing_Elements
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // Колко пъти в поредицата числа ... едно от числата са по големи от предходното
  14.  
  15.  
  16. var n = int.Parse(Console.ReadLine());
  17.  
  18. int counter = 0;
  19. var a1 = 0;
  20. // var a1 = int.Parse(Console.ReadLine());
  21. // Console.WriteLine("tova e a1 >>>>> {0}", a1);
  22. var a3 = 0;
  23.  
  24. for (int i = 0; i < n - 1 ; i++)
  25. {
  26. if (i == 0)
  27. {
  28. a1 = n;
  29. //Console.WriteLine("tova e a1 >>>>> {0}", a1);
  30. }
  31.  
  32.  
  33. var a2 = int.Parse(Console.ReadLine());
  34. // Console.WriteLine("tova e a2 >>>>> {0}", a2);
  35.  
  36. if ( a1 > a2 )
  37. {
  38. a3 = Math.Min(a1, a2);
  39. // Console.WriteLine("tova e a3 >>>>> {0}", a3);
  40. }
  41.  
  42.  
  43.  
  44. if (a3 < a2)
  45. {
  46. a3 = Math.Max(a1, a2);
  47. // Console.WriteLine("tova e Max a3 >>>>> {0}", a3);
  48.  
  49. }
  50.  
  51. if (a3 > a1)
  52. {
  53. counter++;
  54. // Console.WriteLine("tova e counter >>>>> {0}", counter);
  55. }
  56.  
  57. a1 = a3;
  58. // Console.WriteLine("tova e a1 >>>>> {0}", a1);
  59.  
  60.  
  61.  
  62. }
  63.  
  64.  
  65. Console.WriteLine("{0}" , counter);
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. // НЕ Е ВАЖНО ТУКА НАДОЛУ :)
  76.  
  77.  
  78. /*var n = int.Parse(Console.ReadLine());
  79. var num1 = int.Parse(Console.ReadLine());
  80. var counter = 0;
  81.  
  82.  
  83.  
  84.  
  85. for ( int i = 0; i < n - 1; i++)
  86. {
  87. var a1 = int.Parse(Console.ReadLine());
  88.  
  89. if (num1 > a1)
  90. {
  91. num1 = a1;
  92. }
  93.  
  94. else
  95. {
  96. counter = counter + 2;
  97. num1 = a1;
  98. }
  99. }
  100.  
  101. Console.WriteLine(counter); // */
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement