| 12345678910111213141516171819202122232425262728293031323334353637 |
- #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;
- }
|