Seal_of_approval

Pr6R2ex20

Sep 18th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1.  using System;
  2.  
  3. namespace test
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int[] array;
  10.             Console.Write ("n = ");
  11.             int n = int.Parse (Console.ReadLine ());
  12.             array = new int[n];
  13.  
  14.             for (int i = 0; i < n; i++) {
  15.                 Console.Write ("array[{0}] = ", i);
  16.                 array [i] = int.Parse (Console.ReadLine ());
  17.             }
  18.  
  19.             int count = 0;
  20.             int j = 1;
  21.             for (int i = 0; j <= n - 1; i++, j++)
  22.                 if (array [i] < array [j])
  23.                     count++;
  24.             Console.WriteLine ("Answer = {0}", count);
  25.  
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment