代码:

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
int up1,down1,up2,down2; do{
printf("Enter two fractions seperated by a plus sign:");
scanf("%d/%d+%d/%d",&up1,&down1,&up2,&down2);
int down3=down1*down2;
int up3=up1*down2+up2*down1; int small=(up3<down3)?up3:down3;
int gcd;
for(;small>;small--){
if(up3%small== && down3%small==)
{
gcd=small;
break;
}
} printf("The sum is %d/%d\n",up3/gcd,down3/gcd);
}while(up1!=); return ;
}

代码:

Enter two fractions seperated by a plus sign:/+/
The sum is /
Enter two fractions seperated by a plus sign:/+/
The sum is /
Enter two fractions seperated by a plus sign:/+/
The sum is /
Enter two fractions seperated by a plus sign:/+/
The sum is /
Enter two fractions seperated by a plus sign:/+/
The sum is /

--2020年6月9日--

最新文章

  1. html5 自定义标签取值
  2. 使用jquery-qrcode生成二维码
  3. tomcat 7/8 启动非常慢的解决方法
  4. php示例代码之使用mysql_fetch_object函数
  5. primefaces 上传文件尺寸受限制 Connection terminated as request was larger than
  6. Redis 的 5 个常见使用场景
  7. 值得学习的C语言开源项目
  8. Python之Flask Web开发
  9. js密码强度
  10. Codeforces Beta Round #51 B. Smallest number dfs
  11. 基于内嵌Tomcat的应用开发
  12. delphi xe5 android sample 中的 SimpleList 是怎样绑定的
  13. clone Control event handlers at run time
  14. 【Zookeeper】3.4.9 基本配置
  15. 新手了解.Nat
  16. 用Maven快速生成带有依赖的可执行jar包
  17. Python中数学函数
  18. spring boot 2.0 neo4j 使用
  19. html5dom2
  20. NIO 之 ByteBuffer

热门文章

  1. Tomcat Windows 内存设置
  2. ubuntu升级已安装git版本
  3. 防御sqlmap攻击之动态代码防御机制
  4. 用WindowsAPI实现文件复制功能
  5. PowerJob 的自实现高可用方案,妙妙妙!
  6. C++ U型数
  7. 进阶6:连接查询 一、sql92标准
  8. Devops与敏捷二者能否结合?
  9. ucore lab2
  10. xfs文件系统修复方法