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 }
原文地址:https://www.cnblogs.com/yelan/p/2923456.html