June 2022 1 15 Report
Zmień w kodzie C++ aby zamiast od razu wyniku, było można wpisać daną liczbę i wtedy podany zostanie wynik z reszty. (Trzeba ten WydajReszte(7.40) jakoś zmienić na cout itp.)

#include

using namespace std;

const int N = 9;
const float NOMINALY[N] = { 5, 2, 1, 0.50, 0.20, 0.10, 0.05, 0.02, 0.01 };

void WydajReszte(double reszta)
{
int i = 0;
while (reszta > 0 && i < N)
{
if (reszta >= NOMINALY[i])
{
cout << NOMINALY[i] << endl;
reszta = reszta - NOMINALY[i];
}
else i++;
}
}


int main()
{
WydajReszte(7.40);
return 0;
}

Recommend Questions



Life Enjoy

" Life is not a problem to be solved but a reality to be experienced! "

Get in touch

Social

© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.