I have a big doubt into converting an integer into an array in C++.
So, actually the doubt is in using this array<int,5>. How do i use it? B/c i need to do these things: get an integer, then make that integer be an array. Example: if i enter 25, it should return [10,5,5,5]
1 2 3 4 5 6 7 8 9 10
array<int, 5> function_name(int integer, int other_integer=10);
int main(){
int consumo;
cout << "Enter the consumption:" << endl;
cin >> consumo;
}
they are intervals, so the [10,5,5,5,0](i forgot this one) is because the first interval goes from 1 to 10, the second from 11 to 15, the third from 16 to 21, the forth from 21 to 50 and the fifth from 51 to infinite. And the minimum value it's 10, so if i enter 34, it must return [10,5,5,14,0]
Set all elements to zero
If number less than 11
then first element is 10 and finish
otherwise subtract 5,5 and 5 progressively, and processing remainders including any final remainder in the fifth element.