Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <Windows.h>
  3. #include <stdio.h>
  4. #include <math.h>
  5. void Zbutku(int *a, int size)
  6. {
  7. int i, j;
  8. float ser_sum_zbutku, sum_zbutku = 0, k = 0;
  9. for (i = 0; i < size; i++, a++)
  10. for (j = 0; j < size; j++, a++)
  11. {
  12. if (*a < 0)
  13. {
  14.  
  15. sum_zbutku += *a;
  16. k++;
  17. }
  18. }
  19. printf("Сума збитків=%f\n", sum_zbutku);
  20. ser_sum_zbutku = sum_zbutku / k++;
  21. printf("Кількіть збитків=%f\n", k);
  22. printf("Середнє арифметичне значення усіх збитків:%f\n", ser_sum_zbutku);
  23. }
  24. void Prybutky(int *a, int size)
  25. {
  26. int i, j;
  27. float ser_sum_prybutky, sum_prybutky = 0, w = 0;
  28. for (i = 0; i < size; i++, a++)
  29. for (j = 0; j < 5; j++, a++)
  30. {
  31. if (*a > 0)
  32. {
  33.  
  34. sum_prybutky += *a;
  35. w++;
  36. }
  37. }
  38. printf("Сума прибутків=%f\n", sum_prybutky);
  39. ser_sum_prybutky = sum_prybutky / w++;
  40. printf("Кількість прибутків=%f\n", w);
  41. printf("Середнє арифметичне значення усіх прибутків:%f\n", ser_sum_prybutky);
  42.  
  43. }
  44. int main()
  45. {
  46. SetConsoleCP(1251);
  47. SetConsoleOutputCP(1251);
  48. int x[6][6] = { { -2 , 10 , 15 , -5 , -7 },
  49. { -15 , 5 , 23 , -7 , -6 },
  50. { -7 , 5 , 4 , 5 , -15 },
  51. { 5 , 54 , -24 , 4 , 2 },
  52. { -5 , -4 , 25 , 4 , 3 }
  53. };
  54. Zbutku(x, 6);
  55. Prybutku(x, 6);
  56. return 0;
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement