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

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

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

2019-11-10 21:35:34
字體:
供稿:網(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ā)表
主站蜘蛛池模板: 北京市| 青海省| 平武县| 大荔县| 上饶市| 班戈县| 二连浩特市| 南丰县| 惠来县| 酒泉市| 清水县| 寻乌县| 通城县| 罗平县| 夹江县| 舞阳县| 长顺县| 日喀则市| 湘潭市| 穆棱市| 钟山县| 齐齐哈尔市| 都江堰市| 和静县| 大宁县| 开化县| 白朗县| 岚皋县| 庆阳市| 金溪县| 罗源县| 浠水县| 新建县| 邮箱| 英山县| 南木林县| 阿克陶县| 绥芬河市| 三明市| 苏州市| 陇西县|