Advertisement
InnaSibirova

Rus 6

Dec 18th, 2021
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4. int main() {
  5.     int arr[1000];
  6.     int n;
  7.     scanf("%d", &n);
  8.     for(int i = 0; i < 1000; i++) {
  9.         arr[i] = 0;
  10.     }
  11.     for(int i = 0; i < n; i += 1) {
  12.         scanf("%d", &arr[i]);
  13.     }
  14.     for(int i = 0; i < n; i += 1) {
  15.         if(arr[i] > 0) {
  16.             n += 1;
  17.             for(int j = i + 1; j < n; j += 1) {
  18.                 arr[j] = arr[i];
  19.             }
  20.             arr[i] = 0;
  21.             i += 1;
  22.         }
  23.     }
  24.     for(int i = 0; i < n; i += 1) {
  25.         printf("%d", arr[i]);
  26.     }
  27.     return 0;
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement