本题链接:201509-1 数列分段
本博客给出本题截图:
C++
#include <iostream>
using namespace std;
const int N = 1010;
int n;
int q[N];
int main()
{
cin >> n;
for (int i = 0; i < n; i ++ ) cin >> q[i];
int res = 1;
for (int i = 1; i < n; i ++ )
if (q[i] != q[i - 1])
res ++ ;
cout << res << endl;
return 0;
}
总结
水题,不解释