How to use the biggest value?

Hi! I'm a beginner.

I have 4 main values: k = 355; 1var; 2var; 3var; - random values
And the main object comes with 3 steps:

1.Finding biggest value;
2.Arranging;
3.Final - output;

The objective is to find the biggest value (that what this program does) and if
we find out that: k - (BoxN*144) or (BundleN*12) or PairN != 0; Then program has to go back to the process of number arranging without the value that was the biggest;
At the end result should be: Box number:2; Bundle number: 5, Pair number: 7;

Simple as that! But sadly I'm not experienced enough to solve this.


For more details this program is about buying boxes (*aoi = BoxN*144),
bundles (*aoi = BundleN*12),
or pairs of socks (*aoi = 1)
And the goal is to buy them most efficient way; If you can't use the most efficients way**, then use second as much efficient way, it is determined from values - var1, var2, var3;

*aoi - amount of items in it is calculated by:
**can't use because of the too big amount of number is being buyed e.x. need to buy 12 items so it can't be done with a box, because we buy 144-12=132 too many of it.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
   int k = 355, //total number
   x = 1, //useful in arranging
   nb = 144, //number in box
   nbun = 12, //number in bundle

   var1 = 59, //random number
   var2 = 84, //random number
   var3 = 144; //random number

    //Finding biggest value

    int array[3] = {var1, var2, var3};
    int temp = 0;

    for(int i=0;i<3;i++)
    {if (array[i]>temp) {temp=array[i];}}

//arranging

int BoxN = 0, BundleN = 0, PairN = 0;

    if (var3 == temp){
    while (k - x * nb >= 0)
    {
        x = x + 1;
        BoxN = BoxN + 1;

    }
    }
    else if (var2 == temp){
    while (k - x * nbun >= 0)
    {
        x = x + 1;
        BundleN = BundleN + 1;
    }
    }
    else {
    while (k - x * 1 >= 0)
    {
        x = x + 1;
        PairN = PairN + 1;
    }
    }

//final

cout << "Box number: " << setw(7) << fixed << setprecision(0) << BoxN << '\n';
cout << "Bundle number: " << setw(4) << fixed << setprecision(0) << BundleN << '\n';
cout << "Pair number: " << setw(6) << fixed << setprecision(0) << PairN << '\n';
return 0;
}



check my previous post where my question was asked before.
ask if something is unclear

And HUGE thank you! For anyone who will help me even if this task is just not corresponds your status or abilities.
Topic archived. No new replies allowed.