Advertisement
Josif_tepe

Untitled

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