Advertisement
AI_UBI

Count of numbers beteween few numbers

Dec 2nd, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. unsigned check(int *Items, int *Count)
  2. {
  3.     int max = 0, start = 0, end = 0, tick = 0;
  4.    
  5.     for (; tick < *Count; tick++)
  6.     {
  7.         if (Items[tick] > max)
  8.         {
  9.             max = Items[tick];
  10.             start = end = tick;
  11.         }
  12.         else if (Items[tick] == max)
  13.         {
  14.             end = tick;
  15.         }
  16.     }
  17.  
  18.     return start == end ? 0 : (((tick + end) - (tick + start)) - 1);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement