Josif_tepe

Untitled

Aug 27th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6. int main() {
  7.    
  8.     int n;
  9.     scanf("%d", &n);
  10.    
  11.     float niza[n];
  12.     for(int i = 0; i < n; i++) {
  13.         scanf("%f", &niza[i]);
  14.     }
  15.    
  16.     float sredna_vrednost = 0.0;
  17.     for(int i = 0; i < n; i++) {
  18.         sredna_vrednost += niza[i];
  19.     }
  20.     sredna_vrednost /= n;
  21.    
  22.     float nova_niza[n];
  23.    
  24.     for(int i = 0; i < n; i++) {
  25.         nova_niza[i] = fabs(niza[i] - sredna_vrednost);
  26.     }
  27.    
  28.     for(int i = 0; i < n; i++) {
  29.         printf("%f ", nova_niza[i]);
  30.     }
  31.    
  32.    
  33.     return 0;
  34. }
  35.  
  36. /*
  37.  8
  38.  1.3 0.7  7.0   2.5  3.3  14.9  5.1  2.24
  39.  **/
  40.  
Advertisement
Add Comment
Please, Sign In to add comment