Advertisement
Halas

Sumaart

May 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. float F(int N, float x[])
  6. {
  7. float suma;
  8. float sumaart;
  9. int licz;
  10. licz=0;
  11. suma=0;
  12. sumaart=0;
  13. int i;
  14. for(i=0; i<N; i++)
  15. {
  16. suma+=x[i];
  17. }
  18. sumaart=suma/N;
  19. for(i=0; i<N; i++)
  20. {
  21. if(x[i]==sumaart)
  22. licz++;
  23. }
  24. return licz;
  25. }
  26.  
  27. int main(int argc, char *argv[]) {
  28. printf("Podaj ilosc elementow w tablicy: ");
  29. int N, i, licznik;
  30. scanf("%i", &N);
  31. float x[N];
  32. for(i=0; i<N; i++)
  33. {
  34. printf("Podaj element tablicy x: ");
  35. scanf("%f", &x[i]);
  36. }
  37. licznik=F(N, x);
  38. printf("\nIlosc elementow w x: %i", licznik);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement