# 求两个整分数之和，形式：cout << a << dummy << b

-2

Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.

#include<iostream.h>

int Greatest_Common_Divors(int max, int min)
{
int temp , i , min1, max1 , max_temp , min_temp;

temp = max % min ;

if(temp != 0)
{
for(i=2; i< max/2 ; i++)
{
max1 = max % i;
min1 = min % i;

max_temp = max / i;
min_temp = min / i;

if(max1 == min1)
{
if((max_temp * min) == (min_temp * max))
{
return (max * min_temp);

break;
}
}
}
}

else
{
return max;

}

}

void
main()

{
int Greatest_Common_Divors(int max, int min);

int  add , temp1;

int a , b, x, y;

cout << "请你以该种方式输入两个整分数 ： a / b --->先输入a , 再输入b\n";

a = cin.get();
b = cin.get();
x = cin.get();
y = cin.get();

if(b >= y)
{
temp1 = Greatest_Common_Divors(b,y);
}
else
{
temp1 = Greatest_Common_Divors(y,b);
}
add  = a * (temp1 / y) +  x * (temp1 / b);

cout << add << " / " << temp1 ;

cout << endl;
}

0

zsounder | 园豆：2819 (老鸟四级) | 2012-04-18 14:54
0
artwl | 园豆：16536 (专家六级) | 2012-04-18 20:09

您需要登录以后才能回答，未注册用户请先注册