Advertisement
cd62131

Shrink

Jul 23rd, 2014
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main() {
  5.   int n;
  6.   vector<int> a;
  7.   cin >> n;
  8.   for (int i = 0; i < n; i++)
  9.     a.push_back(i);
  10.   cout << "a contains: ";
  11.   for (size_t i = 0; i < a.size(); i++)
  12.     cout << a[i] << ' ';
  13.   cout << endl;
  14.  
  15.   for (int i = 0; i < n - 1; i++)
  16.     a[i] += a[i + 1];
  17.   a.erase(a.end() - 1);
  18.   cout << "a contains: ";
  19.   for (size_t i = 0; i < a.size(); i++)
  20.     cout << a[i] << ' ';
  21.   cout << endl;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement