当前位置:网站首页>Daily practice of C language - day 80: currency change
Daily practice of C language - day 80: currency change
2022-07-01 09:01:00 【Xiaohui_ Super】
C Practice your language every day
2022 year 2 month 13 Japan
List of articles
Title Description
take 5 RMB yuan into 1 element 、5 Angular sum 1 Dimes , How many different exchange methods are there .
Problem analysis
list 3 element 1 Sub equation 10x+5y+z=50 All the solutions of
Code implementation
#include <stdio.h>
int main()
{
int one_yuan = 0, five_jiao = 0, one_jiao = 0;
int cnt = 0; // Number of exchange methods
for(one_yuan = 0; one_yuan <= 5; one_yuan++)
for(five_jiao = 0; five_jiao <= 10; five_jiao++)
for(one_jiao = 0; one_jiao <= 50; one_jiao++)
if(one_yuan * 10 + five_jiao * 5 + one_jiao == 50)
{
cnt++;
printf("%2d gold 1 element %2d gold 5 horn %2d gold 1 horn \t ", one_yuan, five_jiao, one_jiao);
if(cnt % 3 == 0)
printf("\n");
}
printf("\n in total %d There are two methods of exchange \n", cnt);
return 0;
}
Running results

边栏推荐
猜你喜欢

Introduction to 18mnmo4-5 steel plate executive standard and delivery status of 18mnmo4-5 steel plate, European standard steel plate 18mnmo4-5 fixed rolling

1. Connection between Jetson and camera

个人装修笔记

安装Oracle EE

C语言指针的进阶(上篇)

Redis -- lattice connects to redis cluster

Principles of Microcomputer - Introduction

小鸟识别APP

FreeRTOS learning easy notes

Why is the Ltd independent station a Web3.0 website!
随机推荐
ARM v7的体系结构A、R、M区别,分别应用在什么领域?
Is it safe to dig up money and make new shares
Screenshot tips
Shell脚本-变量的定义、赋值和删除
Shell script -for loop and for int loop
Set the type of the input tag to number, and remove the up and down arrows
Software Engineer Interview Question brushing website and experience method
Understanding and implementation of AVL tree
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
Mysql 优化
Flink interview questions
Yidian Yidong helps enterprises to efficiently manage equipment and improve equipment utilization
Nacos - service discovery
中小企业固定资产管理办法哪种好?
通过 代码实例 理解 浅复制 与 深复制
Pain points and solutions of equipment management in large factories
Shell script case in and regular expressions
3. Detailed explanation of Modbus communication protocol
Why is the Ltd independent station a Web3.0 website!
[MFC development (16)] tree control