multiples of an integer

I need an easy way to stop my iterations at a certain number plus its multiples so that i can output a specific character every time I reach that value " c " (and multiples). The current example with two multiples Im using works fine but for big tables i want to have a flexible number of multiples I can handle.

Thanks for your help


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void print_matrix(int matrix[LENGTH][LENGTH], int c)
{
	int i;
	int j;
	for(j=1; j<=LENGTH; j++)
	{
		for(i=1; i<=LENGTH; i++)
		{cout << matrix[i][j] << " ";
		if(i==c||i==2*c)
			 cout << "| ";
		}
		cout << endl;
		if(j==c||j==2*c)
			cout << "----------------------" << endl;
	}
}
Last edited on
If I understand the question, that is the answer: you can use !(i % c) for all multiplies or !(i % c) && (i / c <= max_multiple) for some of them.
Topic archived. No new replies allowed.