Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int n = 10;
- int a[n];
- int i, j, x;
- cout << "Enter array" << endl;
- for (i = 0; i < n; i++)
- {
- cout << "\n a[" << i << "]= ";
- cin >> a[i];
- }
- for (i = 1; i < n; i++)
- {
- for (j = n - 1; j >= i; j--)
- {
- if ((a[j]==0) && (a[j - 1] != 0))
- {
- x = a[j-1];
- a[j - 1] = a[j];
- a[j] = x;
- }
- }
- }
- for (i = 0; i < n; i++)
- cout << "\n a[" << i << "]=" << a[i];
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement