当前位置:网站首页>C语言经典例题-求最少数量钞票
C语言经典例题-求最少数量钞票
2022-07-23 10:47:00 【Blue_lan18】
编写一个程序,要求用户输入一个美金数量,然后显示出如何用最少的20美元、10美元、5美元和1美元来付款:
# include <stdio.h>
int main()
{
int amount;
int twentyDollars = 0;//定义20美元钞票数量
int tenDollars = 0;
int fiveDollars = 0;
int oneDollars = 0;
printf("Enter an dollar amount: ");
scanf("%d", &amount);
twentyDollars = amount / 20;
tenDollars = (amount - twentyDollars *20) / 10;//计算10美元钞票数量
fiveDollars = (amount - twentyDollars *20 - tenDollars *10) / 5;
oneDollars = amount - twentyDollars *20 - tenDollars *10- fiveDollars;
printf("$20 bills: %d\n", twentyDollars);
printf("$10 bills: %d\n", tenDollars);
printf("$5 bills: %d\n", fiveDollars);
printf("$1 bills: %d\n", oneDollars);
return 0;
}
边栏推荐
- Start other independent programs through fmmonitoredprocess in unreal
- 信号量
- Unreal中通过FMonitoredProcess启动其他独立程序
- [ctfhub] the data of JWT header and payload are transmitted in clear text. If sensitive information is contained in it, sensitive information will be leaked. Try to find the flag. Format is flag{}
- 修改ssh命令行[[email protected]]#颜色
- 老照片上色——DeOldify快速上手
- Blazor快速实现扫雷(MineSweeper)
- After vscode is updated, the shortcut keys related to tab cannot be used
- Exploration and practice of Ali multimodal knowledge atlas
- 152. Product maximum subarray
猜你喜欢

Clickhouse, let the query fly!!!

Matlab simulation of depth information extraction and target ranging based on binocular camera images

安全合理用电 收获清凉一“夏”

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

基于PSO优化的多目标最优值求解matlab仿真
[email protected]]#颜色"/>修改ssh命令行[[email protected]]#颜色

查找论文源代码

老照片上色——DeOldify快速上手

基于matlab的CBOC信号调制解调仿真,输出其相关性,功率谱以及频偏跟踪
![[200 opencv routines] 225. Fourier descriptor for feature extraction](/img/4b/1f373505ffd5c0dbaa5c20431c4b42.png)
[200 opencv routines] 225. Fourier descriptor for feature extraction
随机推荐
开源四足机器人 附设计图及代码「建议收藏」
Error | cannot read property '_ normalized‘ of undefined
第四章 使用 %REST.API 类创建 REST 服务
Where can I download airserver? How to use tutorial
Matlab simulation of solving multi-objective optimal value based on PSO optimization
raid homes and plunder houses!
The official redis visualization tool is coming. The needle doesn't poke
RSA加密的使用
Six ways of uniapp route jump
基于matlab的CBOC信号调制解调仿真,输出其相关性,功率谱以及频偏跟踪
Axure进阶
Deep understanding of CAS (spin lock)
基於matlab的CBOC信號調制解調仿真,輸出其相關性,功率譜以及頻偏跟踪
Redis布隆过滤器
String与Integer互相转换
Monotonous stack!!!
airserver在哪里下载?使用方法教程
第二篇 如何设计一个RBAC权限系统
[pyGame practice] playing poker? Win or lose? This card game makes me forget to eat and sleep.
第三篇 RBAC权限管理 数据库设计详解