当前位置:网站首页>Classic example of C language - find the minimum number of banknotes
Classic example of C language - find the minimum number of banknotes
2022-07-24 00:25:00 【Blue_ lan18】
Write a program , Ask the user to enter a dollar amount , Then show how to use the least 20 dollar 、10 dollar 、5 The dollar and 1 Dollars to pay :
# include <stdio.h>
int main()
{
int amount;
int twentyDollars = 0;// Definition 20 Number of US dollar bills
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;// Calculation 10 Number of US dollar bills
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;
}
边栏推荐
- Redis distributed lock to be continued
- AWS Part 4 one machine and one secret
- [wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)
- MySQL table field quantity limit and row size limit
- Gbase 8C string Operator
- 加密技术应用
- Problem note - unable to open include file: "direct.h": no such file or directory
- Detailed explanation of data warehouse standard -2022
- 【Android Kotlin】Property、Getter 和 Setter
- GBase 8c访问权限查询函数(六)
猜你喜欢

The universal esp32c3 configures partition tables based on the Arduino ide framework

Comparison of the shortcomings of redis master-slave, sentinel and cluster architectures

The implementation in Oracle replaces the specified content of the specified column with the desired content

Unity metaverse (I). Ready player me & blender customize your Avatar

Delete all data of specified query criteria in Oracle
![[Android kotlin] property, getter and setter](/img/f7/a3b79e3f7c4396a240eb5749c450d3.png)
[Android kotlin] property, getter and setter

English语法_指示代词 - So

Flutter | the easiest way to add header and footer to listview

Docker builds sonarqube, mysql5.7 environment

Summarize the plan, clarify the direction, concentrate and start a new situation -- the Counterpart Assistance Project of hexu software has achieved remarkable results
随机推荐
Gbase 8C string Operator
泛型机制和增强for循环
总结谋划明方向 凝心聚力开新局——和数软件对口援疆项目显成效
What are blue-green deployment, Canary release and a/b test
Résumé du websocket minier
Table custom table encapsulation
Gbase 8C access authority query function (6)
docker搭建sonarqube,mysql5.7环境
GBase 8c 位串操作符(一)
Gbase 8C system table information function (II)
Redis分布式锁待续
It basic English
CA digital certificate
Flutter | the easiest way to add header and footer to listview
The prediction of domestic AI protein structure reproduced a breakthrough and solved the 3D structure with a single sequence. Peng Jian's team: "the last piece of puzzle since alphafold2 has been comp
Pytest interface automated testing framework | how to get help
高数_第2章多元函数微分学__偏导数的几何应用_空间曲线的切线与法平面
NGFW portal authentication experiment
MySQL client to server character set conversion
Understanding polymorphism and letting different "people" do the same thing will produce different results