首页 > 代码库 > CCF_201509-1_数列分段

CCF_201509-1_数列分段

水。

 

#include<iostream>#include<cstdio>using namespace std;int main(){    int n,a[1005];    cin >> n;    for(int i = 1;i <= n;i++)   cin >> a[i];    int now = a[1],num = 1;    for(int i = 2;i <= n;i++)    {        if(now != a[i])        {            num++;            now = a[i];        }    }    cout << num << endl;}

 

CCF_201509-1_数列分段