C++ ~ cin to array and output use vector, for_each

#include <iostream>
#include <vector>
#include <algorithm>


int inputNumber = 1 ;
vector<int> inputArray;
while(inputNumber != 0)
{
cin>>inputNumber;
inputArray.push_back(inputNumber);
}
for_each (inputArray.begin(), inputArray.end(), myfunction);



reference
http://www.cplusplus.com/reference/algorithm/for_each/

http://stackoverflow.com/questions/3807163/stdcin-in-an-array

沒有留言: