String Division Question

How would one best tell how many times a string could be divided into blocks. Like say how many times a string 128 can be divided into 32 parts, I've made an attempt to do this however it is rather sketchy.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int theSize = 32;

int getBinsPerString(int theSize)
{
	int theTotal(0);
	int round(0);
	int numberOfBins(0);	
	while(true)
	{
		if(theTotal == theSize+1){break;}
		if(round == theSize)
		{
			cout << "gear" << endl;
			numberOfBins = numberOfBins + 1;
			round = 0;
		}
		round = round + 1;
		theTotal = theTotal + 1;
	}
	return numberOfBins;
}
I'm not sure if this is what you're talking about but here's what I made real quick.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace std;

int main()
{
    int size = 32;
    int blocks = 0;

    cout << "Please give me a number of blocks." << endl;
    while (cin >> blocks)
        cout << "The number of times the blocks can be divided by 32 is " << blocks/size << " with a remainder of " << blocks%size << endl;
}



If you put in 50 you'll get a result of 1 with a remainder of 18.
Last edited on
Thank you
Topic archived. No new replies allowed.