Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <Windows.h>
- #include <stdio.h>
- #include <math.h>
- void Zbutku(int *a, int size)
- {
- int i, j;
- float ser_sum_zbutku, sum_zbutku = 0, k = 0;
- for (i = 0; i < size; i++, a++)
- for (j = 0; j < size; j++, a++)
- {
- if (*a < 0)
- {
- sum_zbutku += *a;
- k++;
- }
- }
- printf("Сума збитків=%f\n", sum_zbutku);
- ser_sum_zbutku = sum_zbutku / k++;
- printf("Кількіть збитків=%f\n", k);
- printf("Середнє арифметичне значення усіх збитків:%f\n", ser_sum_zbutku);
- }
- void Prybutky(int *a, int size)
- {
- int i, j;
- float ser_sum_prybutky, sum_prybutky = 0, w = 0;
- for (i = 0; i < size; i++, a++)
- for (j = 0; j < 5; j++, a++)
- {
- if (*a > 0)
- {
- sum_prybutky += *a;
- w++;
- }
- }
- printf("Сума прибутків=%f\n", sum_prybutky);
- ser_sum_prybutky = sum_prybutky / w++;
- printf("Кількість прибутків=%f\n", w);
- printf("Середнє арифметичне значення усіх прибутків:%f\n", ser_sum_prybutky);
- }
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int x[6][6] = { { -2 , 10 , 15 , -5 , -7 },
- { -15 , 5 , 23 , -7 , -6 },
- { -7 , 5 , 4 , 5 , -15 },
- { 5 , 54 , -24 , 4 , 2 },
- { -5 , -4 , 25 , 4 , 3 }
- };
- Zbutku(x, 6);
- Prybutku(x, 6);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement