OJ_1189找零钱
来源:互联网 发布:怎么看淘宝买家好评率 编辑:程序博客网 时间:2024/04/29 16:25
神tm找零钱。
注意算法,出版算法po主写了一堆if然后把自己绕晕了。
有时候,思路是对的时候,思维需要转一个弯。
#include <stdio.h>#include <stdlib.h>int main(){ int give,spend,back; int t;while(scanf("%d %d",&give,&spend)!=EOF){back=give-spend;printf("%d\n",back);t=back/50;if(t!=0){printf("50*%d",t);back=back%50;}t=back/20;if(t!=0){printf("+20*%d",t);back=back%20;}t=back/10;if(t!=0){printf("+10*%d",t);back=back%10;}t=back/5;if(t!=0){printf("+5*%d",t);back=back%5;}t=back/1;if(t!=0){printf("+1*%d",t);}printf("=%d\n",give-spend);} return 0;}
0 0
- OJ_1189找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱!
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 找零钱
- 动态归化 找零钱
- 移除 logcat 里的杂项信息
- 412. Fizz Buzz
- Unity3D自学笔记——UGUI 利用遮罩显示3D人物(物体)
- java 堆 栈 方法区的简单分析
- Tensorflow Overfitting过拟合解决方法 Dropput()使用方法
- OJ_1189找零钱
- corp finance
- 部分题目整理:大数据
- 中序遍历+后序/先序遍历构建二叉树
- 求最大公约数和最小公倍数的代码
- matlab 非零,求连续数
- 第五章 循环(2)
- 第一篇
- Subsets