自己做老是错的·帮帮忙
来源:百度知道 编辑:UC知道 时间:2024/07/02 06:26:16
a. Function menu: This function informs the user about the program’s purpose, explain how to enter data, and allows the user to select the operations.
b. Function addFractions: This function takes as input four integers representing the numerators and denominators of two fractions, adds the fractions, and returns the numerator and denominator of the result.
c. Function subtractFractions: This function takes as input four integers representing the numerators and denominators of two fractions, substract the fractions, and returns the nume
#include <stdio.h>
void menu(int *a, int *b, int *c, int *d, char *op);
void addFractions(int a, int b, int c, int d, int *e, int *f);
void subFractions(int a, int b, int c, int d, int *e, int *f);
void mulFractions(int a, int b, int c, int d, int *e, int *f);
void divFractions(int a, int b, int c, int d, int *e, int *f);
void simFractions(int a, int b);
int gcd(int a, int b);/* greatest common divisor */
int lcm(int a, int b);/* least common multiple */
void main()
{
int a,b,c,d,e,f;/* a/b and c/d, b!=0, d!=0 */
char op; /* (+,-,*,/) */
menu(&a,&b,&c,&d,&op);
printf("\n%d/%d%c%d/%d", a, b, op, c, d);
switch(op)
{
case '+':addFractions(a,b,c,d,&e,&f);break;
case '-':subFractions(a,b,c,d,&e,&f);break;
case '*':mulFractions(a,b,c,d,&e,&f);break;
case '/':divFractions(a,b