Answer to Question #3753 in C++ for Abilashini nadaraj
2011-07-28T04:46:58-04:00
10,33," "," ",33," ",29,22," ",11," " ," ",92," ",56," ",51
an algoryihm needs to developed to shift all blank values to the end of the array.
1
2011-08-01T08:56:23-0400
#include <iostream> using namespace std; void main() { char a[] = {'1', '2', ' ', '4', ' ', ' ', '7'}; int n = sizeof(a)/sizeof(char); char tmp; for (int i = 0; i < n; i++) // looking for the next blank { & if (a[i] == ' ') & { & for (int j = i; j < n; j++) // looking for the next non-blank to switch & { & if (a[j] != ' ') & { & // make switch & tmp = a[j]; & a[j] = a[i]; & a[i] = tmp; & } & } & } & cout << a[i] << endl; } }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments
Welcome!
Thank you for responding my question i will soon execute this and let u know whether this is right output i expected .
Leave a comment