你看看是这个样子吗?
#include<stdio.h>
int main(void)
{
int num1, demon1,num2,demon2,result_num,result_demon;
char a;
printf("Enter first fraction: ");
scanf("%d/%d",&num1,&demon1);
printf("Enter second fraction: ");
scanf("%d/%d",&num2,&demon2);
printf("Enter a character(+,-,*,/): ");
getchar();
scanf("%c",&a);
switch(a)
{
case '+': result_num=num1*demon2+num2*demon1;
result_demon=demon1*demon2;
printf("The sum is %d/%d\n",result_num,result_demon);
break;
case '-': result_num=num1*demon2-num2*demon1;
result_demon=demon1*demon2;
printf("The sum is %d/%d\n",result_num,result_demon);
break;
case '*': result_num=num1*num2;
result_demon=demon1*demon2;
printf("The sum is %d/%d\n",result_num,result_demon);
break;
case '/': result_num=num1*demon2;
result_demon=num2*demon1;
printf("The sum is %d/%d\n",result_num,result_demon);
break;
default: printf("ERROR!\n");
break;
}
return 0;
}