Advertisement
STANAANDREY

o la sf

Sep 17th, 2019
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, v[1000];
  7.     cin >> n;
  8.     int i = 0, j = 0;
  9.     while (i < n)
  10.     {
  11.         int x;
  12.         cin >> x;
  13.         if (x)
  14.         {
  15.             v[j] = x;
  16.             j++;
  17.         }
  18.         i++;
  19.     }
  20.     while (j < n)
  21.     {
  22.         v[j] = 0;
  23.         j++;
  24.     }
  25.     for (int i = 0; i < n; i++)
  26.         cout << v[i] << ' ';
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement