当前位置:网站首页>C语言经典例题-两个分数相加
C语言经典例题-两个分数相加
2022-07-23 10:47:00 【Blue_lan18】
# include <stdio.h>
int main()
{
int numerator1, numerator2;//定义分子
int denominator1, denominator2;//定义分母
int numerator = 0;
int denominator = 0;
printf("Please input two fractions(Separate with\",\"): ");
scanf("%d/%d, %d/%d", &numerator1, &denominator1, &numerator2, &denominator2);
numerator = numerator1 * denominator2 + numerator2 * denominator1;//最后分数的分子
denominator = denominator1 * denominator2;//最后分数的分母
printf("result = %d/%d\n", numerator, denominator);
return 0;
}
最终结果不是最简分数。
边栏推荐
猜你喜欢

【OpenCV 例程200篇】225. 特征提取之傅里叶描述子

Jsd-2204 session management filter day19

深入理解L1、L2正则化

The exclamation point of vscode +tab shortcut key cannot be used, and the solution to the problem of a-soul-live2d plug-in

在一个有序数组中查找具体的某个数字(二分查找or折半查找)

The landing process of 800V high-voltage fast charging was accelerated, and Junsheng Electronics was designated for the 500million euro project

Error | cannot read property '_ normalized‘ of undefined

BGP federal experiment

Activity的启动流程

Skills to learn before going to primary school
随机推荐
什么是服务器托管及和虚拟主机的区别
颜值爆表 Redis官方可视化工具来啦,针不戳
深入理解L1、L2正则化
如何实现多个传感器与西门子PLC之间485无线通讯?
Matlab simulation of Turbo code error rate performance
基于matlab的BOC调制信号捕获仿真
[pyGame actual combat] aircraft shooting masterpiece: fierce battle in the universe is imminent... This super classic shooting game should also be taken out and restarted~
PostgreSQL has no NVL solution. PostgreSQL queries all tables
【7.16】代码源 -【数组划分】【拆拆】【选数2】【最大公约数】
STL deque
581. Shortest unordered continuous subarray
postgresql没有nvl的解决办法,postgresql查询所有的表
Uniapp realizes horizontal click and slide menu
VSCode的感叹号+tab的快捷键不能用,以及A-SOUL-live2d插件出问题的解决方法
Deep understanding of CAS (spin lock)
Byte stream & character stream of IO stream
第五篇 Druid数据源介绍
Linked list review!
Idea five free plug-ins to improve efficiency
7.13web safety operation