apparently c++ doesn't like it if I have the function try and break the for loop, but i need that function to do so. What would be the proper course of action for this scenario?
The issue is that i have nested for loops, and when one loop gets to its max value, i need it to reset to its min value and break into the next loop so the next loop can iterate. That means I would need goto statements for each loop, and at that point, i might as well nix the function all together.
Name:
Anonymous2009-02-01 12:44
>>4
Hmmm... I think you'll have to use the SICP programming language for this.
Here's the source. I want the program to find combinations of ages for 3 people where the product equals 36. So I set the ages equal to 1 and made a nest of 3 loops. As I have it now, the program goes to the middle loop and iterates 1-36. At that point, I need it to reset the age to one and break into the 2nd loop so that it can iterate to 2, before going back into the inner loop and iterating to 36 again, etc. until all possible combinations are considered.
#include<iostream>
using namespace std;
void print(int w, int x, int y, int z);
void condition(int m, int n);
int main()
{
int a=1, b=1, c=1, d=36;
cout << "Possible ages for sons:" << endl << endl;
for (a;a<=d;a++)
{
print(a,b,c,d);
condition(a,d);
for (b;b<=d;b++)
{
print(a,b,c,d);
condition(b,d);
I know I can simply get rid of the condition function and put the if statement into each loop, but for my own amusement, is there any statement I could use in the function instead of break that would do the job?
>>38
i dont think so.
i was at seoul airport waiting for a flight and the keyboard had some korean mode so i switched to that and did some random keys.
Name:
Anonymous2009-02-03 17:09
i was at Haskoli Island airport waiting for a flight and the keyboard had some "GRUNNUR" mode so i switched to that and did some random keys.
Name:
Anonymous2009-02-03 17:14
i was at java airport waiting for a flight and the keyboard had some "press here for coffee" mode so i switched to that and did some random keys.