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

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

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

2019-11-10 23:00:20
字體:
供稿:網(wǎng)友

甲級傳送門 乙級傳送門

#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)
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 塔城市| 保德县| 南靖县| 依安县| 曲靖市| 金平| 陇川县| 哈巴河县| 云龙县| 农安县| 宜丰县| 宝山区| 莱阳市| 通河县| 蓬安县| 永泰县| 娄烦县| 罗定市| 七台河市| 昌都县| 会昌县| 兴业县| 金昌市| 通许县| 容城县| 驻马店市| 河北区| 寻乌县| 通海县| 塔城市| 温宿县| 外汇| 通渭县| 高台县| 江孜县| 云浮市| 曲麻莱县| 密云县| 英德市| 读书| 宁海县|