主题:[原创]求助大神门!为什么这2道题我错!
上传文件里有题目,反正是求6/12的最简分数的,我为什么错呢?
#include <iostream>
#include <stdlib.h>
int main(void)
{
int a,b,i,number_1,number_2;
printf("enter a fraction:");
scanf("%d/%d\n",&a,&b);
if(a>b){
printf("%d",b);}
else{
printf("%d",a);}
scanf("%d",i);
do {i--;}while(a%i==0&&b%i==0);
number_1=a/i,number_2=b/i;
printf("%d/%d\n",number_1,number_2);
system("PAUSE");
return 0;
}
#include <iostream>
#include <stdlib.h>
int main(void)
{
int a,b,i,number_1,number_2;
printf("enter a fraction:");
scanf("%d/%d\n",&a,&b);
if(a>b){
printf("%d",b);}
else{
printf("%d",a);}
scanf("%d",i);
do {i--;}while(a%i==0&&b%i==0);
number_1=a/i,number_2=b/i;
printf("%d/%d\n",number_1,number_2);
system("PAUSE");
return 0;
}