| 123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <stdio.h>
- #include <math.h>
- int main() {
- double dividend, divisor;
- double quotient, fractional_part;
- int whole_part, count_0125;
- // Запрос ввода чисел у пользователя
- printf("Введите делимое: ");
- scanf("%lf", ÷nd);
- printf("Введите делитель: ");
- scanf("%lf", &divisor);
- // Проверка деления на ноль
- if (divisor == 0) {
- printf("Ошибка: Деление на ноль!\n");
- return 1;
- }
-
- quotient = dividend / divisor;
- whole_part = (int)quotient; // целая часть
- fractional_part = quotient - whole_part; // дробная часть
-
- double count_0125_exact = fractional_part * 8;
- if (count_0125_exact - floor(count_0125_exact) < 0.5) {
- count_0125 = (int)floor(count_0125_exact);
- } else {
- count_0125 = (int)ceil(count_0125_exact);
- }
- printf("Целая часть: %d\n", whole_part);
- printf("Дробная часть: %lf\n", fractional_part);
- printf("Округленное количество единиц 0.125 в дробной части: %d\n", count_0125);
- return 0;
- }
|