将真数分解为埃及分数

问题:

输入一个分数,,将该分数分解为埃及分数。

真分数:分子小于分母的分数

埃及分数:分子为一的分数

#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) {long int a, b, c;scanf("%d%d", &a, &b);while(1){if(b%a)c = b/a+1;else{c = b/a;a=1;}if(a==1){printf("1/%ld\n", c);break;}elseprintf("1/%ld\n", c);a=a*c-b;b=b*c;if(a==3&&b%2==0){printf("1/%ld+1/%ld\n", b/2,b);break;}}return 0;}/*132 1551/21/31/551/10230*/

背着背包的路上,看过许多人,

将真数分解为埃及分数

相关文章:

你感兴趣的文章:

标签云: