I am confused... I mean why its printing 0's?

I have been using vectors for quite a good time.

But…i dont know suddenly this is wrong ???

can u tell me the correct way … ? Or what mistake am i doing ??

#include<bits/stdc++.h>

using namespace std;

int main()

{

int n;

cin>>n;

vector<int>s(n);

for(int i=0;i<n;i++)

{

    int t;

    cin>>t;

    s.push_back(t);

}

for(int i=0;i<n;i++)

{

    cout<<s[i]<<" ";

}

}

When you do s.push_back(t), declare vector as vectors [Note: Not with a size]
Else, if you do vectors(n), just do cin>>s[i]

1 Like

acha…okay

thank you .