【CCF CSP真题连载】2015年09-01题: 数列分段(C++详细版)

【code】

#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,temp,res;
	vector<int> arr;
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
		{
			cin>>temp;
			arr.push_back(temp);
		}

		res = 0;
		for(int i=0;i<n-1;i++)
		{
			while(arr[i] == arr[i+1])
				i++;
			res++;
		}
		res++;
		cout<<res<<endl;
	}

	system("pause");
	return 0;
}

 

相关文章:

  • 2021-09-22
  • 2022-12-23
  • 2021-06-22
  • 2021-08-24
  • 2022-12-23
  • 2021-09-10
  • 2021-11-21
猜你喜欢
  • 2021-12-17
  • 2021-11-04
  • 2021-07-31
  • 2021-04-09
  • 2021-08-11
  • 2021-11-21
  • 2021-09-02
相关资源
相似解决方案