trojanxem

Untitled

Mar 13th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <cstdio>
  2. #include <conio.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     printf("Ile liczb chcesz podac: \n");
  9.     scanf("%d", &n);
  10.     double liczby;
  11.     double suma;
  12.     int ilosc;
  13.     int j;
  14.    
  15.    
  16.     double pom;
  17.    
  18.    
  19.     double a,b;
  20.     printf("Podaj poczatek przedzialu: \n");
  21.     scanf("%d", &a);
  22.     printf("Podaj koniec przedzialu: \n");
  23.     scanf("%d", &b);
  24.     int i;
  25.    for (i = 0; i < n; i++)
  26.   {
  27.        printf("Podaj %d liczbe: \n", i);
  28.     scanf("%lf", &pom);
  29.     if (pom >= a && pom <= b)
  30.     {
  31.       suma += pom;
  32.       ilosc++;
  33.     }
  34.   }
  35.  
  36.   if (ilosc)
  37.     suma /= ilosc;
  38.   else
  39.     suma = 0;
  40.    
  41.   printf("srednia: %lf\n", suma);
  42.   getch();
  43.  
  44.  
  45.   return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment