```cpp
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string colors;
cin >> colors;
int count = 1;
for (int i = 1; i < n; ++i) {
if (colors[i] != colors[i - 1]) {
count++;
}
}
cout << count << endl;
return 0;
}
```
by JoneSno @ 2024-03-24 15:49:06
@[superise](/user/1028446)
by JoneSno @ 2024-03-24 15:49:19
能过吗
by JoneSno @ 2024-03-24 15:49:42
@[JoneSno](/user/1066020) 要用freopen
by superise @ 2024-03-24 15:50:45
@[superise](/user/1028446)
```cpp
#include <iostream>
#include <string>
using namespace std;
int main() {
freopen("count.in", "r", stdin);
freopen("count.out", "w", stdout);
int n;
cin >> n;
string colors;
cin >> colors;
int count = 1;
for (int i = 1; i < n; ++i) {
if (colors[i] != colors[i - 1]) {
count++;
}
}
cout << count << endl;
return 0;
}
```
by JoneSno @ 2024-03-24 15:51:29
@superise,已经有人回了!
by huzhaohua @ 2024-03-24 15:52:10