累算Cの関数を合計++ STL()

累算Cの関数を合計++ STL()

1.1説明と機能のプロトタイプ

accumulate(_InIt _First, _InIt _Last, _Ty _Val)

_Firstそして、_Last蓄積期間、_Val蓄積した初期値。
戻り値の型_Valと同じ。

1.2 int型のアプリケーション

そして、出力配列

	vector<int> testArray = { 1, 2, 3, 4 };
	int sumT = accumulate(testArray.begin(), testArray.end(), 0);

アプリケーションで1.2文字列

char型は文字列型スプライシングです

	vector<char> testChr = { 'l', 'h', 'k' };
	string strSum = accumulate(testChr.begin(), testChr.end(), (string)" ");	\\sunT = "lhk"
公開された13元の記事 ウォンの賞賛1 ビュー297

おすすめ

転載: blog.csdn.net/qq_38670588/article/details/104455535
おすすめ