Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. int towers=0, f=0;
  2.      for(int i=0; i<N-1; i++) {
  3.         if(lns[i]!=lns[i+1]) {
  4.             f=0;
  5.             towers++;
  6.         }
  7.         if(lns[i]==lns[i+1] && f==0) {
  8.             f=1;
  9.             towers++;
  10.         }
  11.     }
  12.     if(N%2!=0)
  13.         towers++;
  14.  
  15.     printf("%d",towers);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement