国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 合江县| 鸡泽县| 固阳县| 禄丰县| 布拖县| 天水市| 义马市| 建水县| 阿拉尔市| 临安市| 开远市| 昌宁县| 开化县| 龙胜| 乌什县| 昆山市| 视频| 武胜县| 巢湖市| 玛沁县| 宾川县| 清丰县| 达日县| 宜兴市| 越西县| 天等县| 余江县| 乌苏市| 浦东新区| 平阴县| 海丰县| 郸城县| 白玉县| 雷山县| 新密市| 乌兰察布市| 广德县| 勃利县| 武威市| 资源县| 奎屯市|