Advertisement
Guest User

Шущвщв

a guest
Apr 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int main() {
  5.  
  6. const int n = 10;
  7. int a[n];
  8. int i, j, x;
  9.  
  10. cout << "Enter array" << endl;
  11. for (i = 0; i < n; i++)
  12. {
  13. cout << "\n a[" << i << "]= ";
  14. cin >> a[i];
  15. }
  16. for (i = 1; i < n; i++)
  17. {
  18. for (j = n - 1; j >= i; j--)
  19. {
  20. if ((a[j]==0) && (a[j - 1] != 0))
  21. {
  22. x = a[j-1];
  23. a[j - 1] = a[j];
  24. a[j] = x;
  25. }
  26. }
  27. }
  28. for (i = 0; i < n; i++)
  29. cout << "\n a[" << i << "]=" << a[i];
  30. system("pause");
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement