#include #include #include #include using namespace std; //myArrya_vector1.cpp also see int deviation(int); int mean; static int total1, total; int main() { ostream_iterator< int> output(cout, " "); int n1[] = { 69, 60, 63, 61, 65, 64, 71, 70, 68, 64 }; cout<<"\n Arrays Length : "< Vint1(n1, n1+10); // copy of n1 vector::iterator it; // iteration cout<< "Using ostream_iterator< int> output(cout, " "); \n\t"; copy(Vint1.begin(), Vint1.end(), output); cout <<"\n ------Using vector in a Loop:------\n "; for (it= Vint1.begin(); it !=Vint1.end(); it++) { cout <<" "<< *it; total1 = total1 + *it; } //cout <<"\n Total : " << total1; mean = total1/10; cout <<"\n Total : " << total1 << " Total/No.obs = avg : " << mean; // cout<<"\n deviation using vector :"; for (it= Vint1.begin(); it !=Vint1.end(); it++) { cout <<" "<< deviation(*it); } // cout << "\n----Array : Data output ----\n"; copy(Vint1.begin(), Vint1.end(), output); cout<< "\n total in each round \n"; for (int i = 0; i <= 9; i++) { cout<<"\t n1 = " << n1[i] ; cout<<" + "<< total << " = " ; total = total + n1[i]; cout<< total << endl; } mean = total/10; cout <<"\n Total : " << total << " Total/No.obs = avg : " << mean; return 0; } int deviation(int value) { int _value; //if(value >= mean){ _value = value - mean ;} //if(value <= mean){ _value = mean - value ;} _value = (mean-value); return _value; }