国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

1034. 有理數四則運算(20)PAT乙級&&1088. Rational Arithmetic (20)PAT甲級

2019-11-11 00:55:26
字體:
來源:轉載
供稿:網友

甲級傳送門 乙級傳送門

#include<stdio.h>#include<math.h>#include <stdlib.h>#include<algorithm>//加上就通過 using namespace std;//加上就通過 typedef long long ll;ll gcd(ll a,ll b){ if(a%b==0) return b; else return gcd(b,a%b);}struct Fraction{ ll down; ll up;}a,b;Fraction reduction(Fraction f){ if(f.down<0){ f.up=-f.up; f.down=-f.down; } if(f.up==0){ f.down=1; } else{ int g=gcd(abs(f.up),abs(f.down)); f.down/=g; f.up/=g; } return f;}Fraction add(Fraction a,Fraction b){ Fraction result; result.down=a.down*b.down; result.up=a.down*b.up+a.up*b.down; return reduction(result);}Fraction minu(Fraction a,Fraction b){ Fraction result; result.down=a.down*b.down; result.up=a.up*b.down-a.down*b.up; return reduction(result);}Fraction mul(Fraction a,Fraction b){ Fraction result; result.down=a.down*b.down; result.up=a.up*b.up; return reduction(result);}Fraction divide(Fraction a,Fraction b){ Fraction result; result.down=a.down*b.up; result.up=a.up*b.down; return reduction(result);}void show(Fraction f){ f=reduction(f); if(f.up<0)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青海省| 枣庄市| 灵台县| 富宁县| 海口市| 丹巴县| 镇康县| 洛宁县| 洪泽县| 海南省| 广元市| 和硕县| 新巴尔虎左旗| 夏津县| 南投市| 岢岚县| 德惠市| 南皮县| 本溪| 鄄城县| 和政县| 乌什县| 宁夏| 上饶县| 文安县| 徐汇区| 元朗区| 岳西县| 崇左市| 正定县| 通州市| 自治县| 岱山县| 闽侯县| 铁岭县| 株洲县| 屯留县| 巴彦县| 稷山县| 延庆县| 南部县|