昆仑山:眼中无形心中有穴之穴人合一

夫君子之行,静以修身,俭以养德;非澹泊无以明志,非宁静无以致远。夫学须静也,才须学也;非学无以广才,非志无以成学。怠慢则不能励精,险躁则不能冶性。年与时驰,意与岁去,遂成枯落,多不接世。悲守穷庐,将复何及!

 

C++STL

前导

#include<iostream>
#include<cstdlib>
using namespace std;

//算法  负责统计元素个数
int count_elements(int*start,int*end,int value)
{
	int num = 0;
	while (start!=end)
	{
		if (*start==value)
		{
			num++;
		}
		start++;
	}
	return num;
}

int main()
{
	/*
	STL: 
		容器(序列式容器,关联式容器)  
		  
		迭代器(相当于指针  默认指向第一个元素)

		算法:通过有限步骤解决问题
	*/
	//数组容器

	int scores[] = {45,67,87,90,54,89,87,87};
	int* pBegin = scores;//迭代器开始位置

	int* pEnd =& (scores[sizeof(scores) / sizeof(int)]);
	int num=count_elements(pBegin, pEnd, 87);
	
	cout << "num:\t" <<num<< endl;

	system("pause");
}

posted on 2019-04-29 15:54  Indian_Mysore  阅读(74)  评论(0编辑  收藏  举报

导航