Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <conio.h>
- #include <math.h>
- int main()
- {
- int n;
- printf("Ile liczb chcesz podac: \n");
- scanf("%d", &n);
- double liczby;
- double suma;
- int ilosc;
- int j;
- double pom;
- double a,b;
- printf("Podaj poczatek przedzialu: \n");
- scanf("%d", &a);
- printf("Podaj koniec przedzialu: \n");
- scanf("%d", &b);
- int i;
- for (i = 0; i < n; i++)
- {
- printf("Podaj %d liczbe: \n", i);
- scanf("%lf", &pom);
- if (pom >= a && pom <= b)
- {
- suma += pom;
- ilosc++;
- }
- }
- if (ilosc)
- suma /= ilosc;
- else
- suma = 0;
- printf("srednia: %lf\n", suma);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment