Stones on the Table

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1487

View Code
 1 #include <stdio.h>
 2 int main()
 3 {
 4     int len, cnt;
 5     char s[55];
 6     while(scanf("%d%s", &len, s)!=EOF)
 7     {
 8         char lastcolor = 0 ;
 9         cnt = 0 ;
10         for(int i=0;i<len;i++)
11         {
12             if(s[i] != lastcolor)
13             {
14                 cnt++ ;
15                 lastcolor = s[i] ;
16             }
17         }
18         printf("%d\n", len - cnt) ;
19     }
20     return 0 ;
21 }

 

posted @ 2013-02-23 15:06  yelan@yelan  阅读(128)  评论(0编辑  收藏  举报