netjunky

Untitled

Nov 9th, 2010
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char **argv)
  5. {
  6.    
  7.     int i = 0, n = 0, c = 0;
  8.     int srednee = 0;
  9.     int sum = 0;
  10.     int min = 0;
  11.    
  12.     int *a;
  13.    
  14.     printf("elementide arv = \n");
  15.    
  16.     scanf("%d", &n);
  17.    
  18.     if( 0 == n )
  19.     {
  20.         return 0;
  21.     }
  22.    
  23.     if( n < 1 || n > 10 )
  24.     {
  25.         return 0;    
  26.     }
  27.    
  28.     a = (int*)malloc( sizeof( int ) * n );
  29.    
  30.     while( i < n )
  31.     {
  32.            printf("vesti chislo:\n");
  33.            scanf("%d", &a[i]);
  34.            
  35.            i++;
  36.            
  37.            sum += a[i];
  38.     }
  39.    
  40.     srednee = sum / n;
  41.    
  42.     printf("Srednee = %d", srednee);
  43.    
  44.     for (i=0; i<n; i--)
  45.     {
  46.         min = a[i] - srednee;        
  47.         if( min > a[i] )
  48.            {
  49.                min = a[i];
  50.            }
  51.        
  52.         }
  53.         while( i < n )
  54.     {
  55.         printf("%d ", min);
  56.     }
  57.    
  58.     free( a );
  59.    
  60.  return 0;
  61. }
Add Comment
Please, Sign In to add comment