国产探花免费观看_亚洲丰满少妇自慰呻吟_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)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 星座| 威海市| 张家口市| 中牟县| 阿拉善盟| 亳州市| 怀安县| 扎兰屯市| 鲁山县| 清新县| 巩义市| 嘉兴市| 遂昌县| 安新县| 酒泉市| 古蔺县| 荥阳市| 灌南县| 湟中县| 沂南县| 锡林郭勒盟| 武乡县| 梅州市| 榆中县| 保定市| 磐安县| 宁陵县| 施秉县| 基隆市| 北京市| 阿坝县| 沂源县| 淮北市| 庆城县| 莲花县| 连城县| 安达市| 长垣县| 富顺县| 富顺县| 巢湖市|