Josif_tepe

Untitled

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