Facebook
From Tom Cruise, 2 Months ago, written in C++.
Embed
Download Paste or View Raw
Hits: 409
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     vector<int> a;
  6.     for(int i=0;i<=5;i++)
  7.     {
  8.         a.push_back(i);
  9.     }
  10.         cout<<"Size: "<<a.size()<<endl;
  11.         cout<<"Capacity: "<<a.capacity()<<endl;
  12.         cout<<"Max Size: "<<a.max_size()<<endl;
  13.         a.resize(4);
  14.         cout<<"Size: "<<a.size()<<endl;
  15.         if(a.empty()==false)
  16.         {
  17.             cout<<"Vector is not empty"<<endl;
  18.         }
  19.         else
  20.         {
  21.             cout<<"Vector isnt empty"<<endl;
  22.         }
  23.         a.shrink_to_fit();
  24.         cout<<"Vector elements are: "<<endl;
  25.         for(auto it=a.begin();it!=a.end();it++)
  26.             cout<<*it<<" "<<endl;
  27.         return 0;
  28. }
  29.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Tom Cruise cpp 2 Months ago.