Advertisement
pushrbx

Iterator v11

Mar 23rd, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <tchar.h>
  3. #include <vector>
  4. #include <iostream>
  5.  
  6. const int NUMCARS = 8;
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10.     int fuel[NUMCARS]={0,2,0,1,1,2,1,0};
  11.     int carPrice[NUMCARS] = {10000, 8500, 22000, 14000, 37000, 18900, 28000, 45000};
  12.  
  13.     vector<int> itAr(fuel, fuel + sizeof(fuel) / sizeof(int));
  14.  
  15.     for(auto& element: itAr)
  16.     {
  17.         cout << "Fuel element: " << element << endl;
  18.     }
  19.  
  20.     itAr.clear();
  21.     itAr.assign(carPrice, carPrice + NUMCARS);
  22.  
  23.     for(auto& element: itAr)
  24.     {
  25.         cout << "CarPrice element: " << element << endl;
  26.     }
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement