Advertisement
InnaSibirova

Rus 6 (rewriting)

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