Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.18 KB | None | 0 0
  1. int count = 1;
  2. for(int i = 0; i < length; ++i)
  3. {
  4.     if (A[i] = A[i+1])
  5.     {
  6.         count++;
  7.     }
  8.     else
  9.     {
  10.         sum += ((count)*(count-1))/2;
  11.         count = 1;
  12.     }
  13. }
  14. sum += ((count)*(count-1))/2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement