http://cppreference.com/cppalgorithm/rev...
Store all the floats in a vector, and then use reverse().
vector%26lt;float%26gt; numbers;
numbers.push_back(3.1f);
numbers.push_back(1.f);
numbers.push_back(7.3916f);
reverse(numbers.begin(), numbers.end());
Function in c++ to reverse an array of float elements?
usin temp variable u can reverse the numbers.
float arr[10];//array of elements
int temp;
for(int i=0;i%26lt;max;i++) //max-%26gt;highest no. of elements.
{for(int j=max-1;j%26gt;=0;j--)
{temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
thats it the array is swapped..
Hope this helps u
Reply:You probably need to create a second array and then get the last elements from the first array and put then in the front of the second array.
Something like this...
# Elements in a
Create 2nd array same size
then something using a while like...
b[firstelement]=a[lastelement]
then
b[1]=a[lastelement-1]
etc.
Just create your own.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment