This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

42 lines
1.1 KiB
C
Executable File

/*
18.Вычислить частное двух обыкновенных дробей. Ответ дать в виде обыкновенной и в виде десятичной дробей. Числители и знаменатели относятся к целому типу данных.
*/
#include <stdio.h>
#include <math.h>
typedef struct Fraction {
int up;
int down;
} fraction;
void printSumFraction(fraction fraction_1, fraction fraction_2) {
int a = fraction_1.up;
int b = fraction_1.down;
int c = fraction_2.up;
int d = fraction_2.down;
/*
a c
- : -
b d
*/
printf("%2d %2d %2d * %2d %2d * %2d %2d\n", a, c, a, d, a, d, a * d);
printf("-- : -- = --- --- = ------- = -- = %.3lf\n", (double)(a * d) / (b * c));
printf("%2d %2d %2d * %2d %2d * %2d %2d\n", b, d, b, c, b, c, b * c);
}
int main()
{
fraction first;
fraction second;
printf("Enter a b c and d: ");
scanf("%d %d %d %d", &first.up, &first.down, &second.up, &second.down);
printSumFraction(first, second);
return 0;
}