Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <math.h>
- #include <algorithm>
- #include <cstdlib>
- using namespace std;
- template<class T> int g(vector<T> *obj){
- vector<T>::iterator p;
- int counter = 0;
- for (p = obj->begin(); p != obj->end(); p++){
- cout << **(p) << " ";
- }
- cout << endl;
- for (p = obj->begin(); p != obj->end(); p++){
- if (p + 1 != obj->end()){
- if (**(p + 1) < 0){
- **p = 0;
- counter++;
- }
- }
- }
- cout << endl;
- for (p = obj->end(); p != obj->begin(); p--){
- cout << **(p-1) << " ";
- }
- cout << endl;
- cout << "counter: ";
- return counter;
- }
- int main(){
- vector<double> doubleVector;
- vector<double>::iterator i;
- for (int i(1); i < 8; i++){
- double temp = pow(-1, i) * 2 * i ;
- doubleVector.push_back(temp);
- }
- vector<double*> pointer;
- for (i = doubleVector.begin(); i != doubleVector.end(); i++)
- {
- pointer.push_back(&(*i));
- }
- cout << endl;
- cout << g(&pointer) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement