<分区>
我正在解决 following programming problem :
URI Online Judge | 1018 - Banknotes
In this problem you have to read an integer number and calculate the smallest possible number of notes in which the value may be decomposed. The notes are of 100, 50, 20, 10, 5, 2 e 1. Print the value read and the list of notes.
Input
The input file contain an integer number N (0 < N < 1000000).
Output
Print the minimum quantity of necessary banknotes, like as the given example.
我尝试了以下解决方案:
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
bool NTrue(int n);
void HowMany(int x, int BankNote);
int main(int argc, char ** argv) {
int N;
cin >> N;
int BankNote = 100;
if (NTrue(N)) {
while (BankNote != 0) {
if (BankNote == 25)
BankNote = 20;
HowMany(N, BankNote);
N = N % BankNote;
BankNote = BankNote / 2;
}
}
return 0;
}
bool NTrue(int n) {
if (0 < n && n <= pow(10, 6))
return true;
else
return false;
}
void HowMany(int x, int BankNote) {
int result = x / BankNote;
float BN = BankNote;
cout << result << " nota(s) de R$ " << fixed << setprecision(2) << BN << endl;
}
我没有得到想要的结果。我做错了什么?