Doubt in using an array

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;

}

Last edited on
if i enter 25, it should return [10,5,5,5]
What's the relation between those two objects? All I can see is 25 = 10+5+5+5. So for the same input, would it be valid to return [1,1,1,22]?
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]
closed account (48T7M4Gy)
So what happens if you enter a number less than 10?
It becomes only [10,0,0,0,0], because it's the minimum value
closed account (48T7M4Gy)
Excellent. So moving along, 13 gives 10,3,0,0,0 ?
That's right! And the doubt is, how to use this c++11 array to do this?
closed account (48T7M4Gy)
Easy, just use the rule you established earlier.

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.
Topic archived. No new replies allowed.