Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int count = 1;
- for(int i = 0; i < length; ++i)
- {
- if (A[i] = A[i+1])
- {
- count++;
- }
- else
- {
- sum += ((count)*(count-1))/2;
- count = 1;
- }
- }
- sum += ((count)*(count-1))/2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement