Hi guys.I need your help about vector. I wrote a method but it does not run. what i want to do is to reverse given vector and method should generate a new vector .I wrote these codes.Please help??
1 2 3 4 5 6 7 8 9 10 11
include<vector>
vector<int>& reverse (const vector<int>& a)
{
int size=a.size();
vector<int> b(size);
for (int i=o; i<size; i++)
{
b[i]=a[size-i-1];
}
return b;
}
Function cannot return a reference.
Use indentation.
'o' is not a number.
1 2 3 4 5 6 7 8 9 10
vector<int> reverse (const vector<int>& a)
{
int size=a.size();
vector<int> b(size);
for (int i = 0; i < size; i++)
{
b[i]=a[size-i-1];
}
return b;
}
Make sure to use the strictest error checking when you compile -- get your compiler to complain about everything it can. It will help you catch a lot of these errors.