trojanxem

Untitled

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