zoukankan      html  css  js  c++  java
  • 华为笔试题11

    • 题目描述:

    假设1元,5元,10元,50元,100元的人民币若干,实现一个能找到最少张数累计达到一个指定金额方法。

    如:67元,可分为67个1元钱。也可分为6个10元7个1元

    其中最少人民币分法为一张50元,一张10元,一张5元,两张1元,五张不同金额的拆分方法为最最少张数拆分法

    • 要求实现函数:

    void CalLeastChange(long lInp

    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	int input=238;
    	int hundred=0;
    	int fifty=0;
    	int decade=0;
    	int five=0;
    	int unit=0;
    
    	hundred=input/100;
    	input=input%100;
    	fifty=input/50;
    	input=input%50;
    	decade=input/10;
    	input=input%10;
    	five=input/5;
    	input=input%5;
    	unit=input/1;
    
    	cout<<hundred<<"*100+ "<<fifty<<"*50+ "<<decade<<"*10+ "<<five<<"*5+ "<<unit<<endl;
    	cout<<hundred+fifty+decade+five+unit;
    	
    	return 0;
    }
    

      

    utValue, int *iOutputRlt)

    【输入】 lInputValue:  输入整数金额

    【输出】 lOutputRlt: 输出计算结果

    【注意】仅考虑整数金额拆分方法

    • 示例

    输入:“67”

    输出:“5”

     

  • 相关阅读:
    Docker理解
    提高服务器并发量,有关系统配置的常规方法
    Linux EXT 文件系统 详解
    jvm入门
    2020-1-08.运维面试题总结
    hexo+gitee
    rsync
    haddop3.2.1完全分布式安装
    zabbix02
    zabbix监控工具问题集
  • 原文地址:https://www.cnblogs.com/xd-jinjian/p/3277214.html
Copyright © 2011-2022 走看看