Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Best way to break?

Name: Anonymous 2009-02-01 12:26

my current hierarchy looks like this:

main()
{
for()
{
function();
}
}

function()
{
if
{
break;
}
}

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?

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !FrOzEn2BUo 2009-02-01 12:28

>>1
Just set the iterator to MAX



_________________________
orbis terrarum delenda est
 http://xs135.xs.to/xs135/09042/av922.jpg

Name: Anonymous 2009-02-01 12:28

goto

Name: Anonymous 2009-02-01 12:39

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: Anonymous 2009-02-01 12:44

>>4
Hmmm... I think you'll have to use the SICP programming language for this.

Name: Anonymous 2009-02-01 12:51

main()
{
for()
{
if function() {
break;
}
}
}

function()
{
if
{
return 1;
}
return 0;
}

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !FrOzEn2BUo 2009-02-01 12:51

>>4
Could you explain how the loops are structured?
 its unclear how its needs to be reset and where is the function in the loop nesting.


_________________________
orbis terrarum delenda est
 http://xs135.xs.to/xs135/09042/av922.jpg

Name: Anonymous 2009-02-01 12:52

[code]main()
{
for()
{
if (!function()) break;
}
}

function()
{
if
{
return false;
}
return true;
}

Name: Anonymous 2009-02-01 12:56

>>8
Why complicate things?

Name: Anonymous 2009-02-01 12:56

>>7

main()
{
    for()
    {
        if function() {
            break;
        }
    }
}

function()
{
    if
    {
        return 1;
    }
    return 0;
}

Name: Anonymous 2009-02-01 13:00

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);
           
            for (c;c<=d;c++)
            {
                print(a,b,c,d);
                condition(c,d);
            }
        }
    }
    system("pause");
    return 0;
}

void print (int w, int x, int y, int z)
{
     if (w*x*y == z)
     {
               cout << "son 1: " << w << endl << "son 2: " << x << endl << "son 3: " << y << endl << "-------------" << endl;
     }
}

void condition(int m, int n)
{
     if (m == n)
     {
           m=1;
           break;
     }
}

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !FrOzEn2BUo 2009-02-01 13:01

>>10
have you tried using ternary instead of if?
function()?"":break;


_________________________
orbis terrarum delenda est
 http://xs135.xs.to/xs135/09042/av922.jpg

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !FrOzEn2BUo 2009-02-01 13:03

>>11
The break is inside the function. It should checked in the loop


_________________________
orbis terrarum delenda est
 http://xs135.xs.to/xs135/09042/av922.jpg

Name: Anonymous 2009-02-01 13:15

>>13

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?

Name: Anonymous 2009-02-01 13:27

break considered harmless

Name: Anonymous 2009-02-01 13:38

>>14
longjmp

Name: Anonymous 2009-02-01 14:13

>>16

Interesting.

Name: bar 2009-02-01 16:46

just testan

Name: Anonymous 2009-02-01 18:13

>>2
>>7
>>12
>>13
Fuck off, faggot.

Name: Anonymous 2009-02-01 18:16

>>19
Why are you replying to nonexistent posts?

Name: Anonymous 2009-02-01 18:45

>>19
I see what you did there

Name: Anonymous 2009-02-01 18:45

>>21
goddamit, i meant to do >>20

Name: Anonymous 2009-02-01 19:21

>>21-22
Was that supposed to be some sort of metajoke about seeing and not seeing?

Name: Anonymous 2009-02-02 4:47

>>23
Was that supposed to be some sort of metajoke about some sort of metajoke about seeing and not seeing?

Name: Anonymous 2009-02-02 7:31

>>24
Was that supposed to be some sort of metatroll joking about some sort of metajoke about seeing and not seeing the metajoke?

Name: Anonymous 2009-02-02 11:05

sure is meta in here

Name: Anonymous 2009-02-02 11:17

I am sorry!

It was just a bad joke!

Name: Anonymous 2009-02-02 21:33

goto is the most elegant solution  for this problem.

댜러ㅏㅈㄷ렂러댜ㅐㅓ

Name: Anonymous 2009-02-02 21:36

>>28
EXPERT KOREAN

Name: Anonymous 2009-02-02 23:15

>>28

valid perl code

Name: Anonymous 2009-02-03 0:59

>>28,29

/prog/

Name: Anonymous 2009-02-03 0:59

>>28,30

/prog/

Name: Anonymous 2009-02-03 1:07

>>30
chrisdesktop:~ chris$ perl -e "댜러ㅏㅈㄷ렂러댜ㅐㅓ"
Unrecognized character \xEB at -e line 1.
chrisdesktop:~ chris$

Name: Anonymous 2009-02-03 2:15

>>1
Good sir, the best way to break is with a Kit Kat bar.

Name: Anonymous 2009-02-03 3:29

>>30
KOREA invented this meme

Name: Anonymous 2009-02-03 7:40

>>33
you need -Mkimchi for that.

Name: Anonymous 2009-02-03 10:42

>>33
use utf8;

댜러ㅏㅈㄷ렂러댜ㅐㅓ;


b:\andrey\>perl kimchi.pl

b:\andrey\>

(I had to save it to file because my terminal sucks and doesn't let me input unicode)

Name: Anonymous 2009-02-03 12:04

>>37
IT'S A VIRUS!

Name: Anonymous 2009-02-03 16:16

>>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: Anonymous 2009-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: Anonymous 2009-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.

Name: Anonymous 2009-02-03 17:50

>>40
Post your code, excellent sir.

Name: Anonymous 2009-03-06 8:15


Will only work on   the new chapter   of my novel.

Name: ​​​​​​​​​​ 2010-10-23 23:05

Name: Anonymous 2011-02-03 4:20

Name: Anonymous 2012-06-16 1:00

         , -‐ 、, -─-- 、.,_
        ,.i (:::)!       `ヽ,. -、
       ./ ゝ-‐'     _____  !. (::)
     _,./__,,. -‐ ''"´ ̄ ̄`"'' .、`ヽ,ー:'
  ,. ''"´ /´ / ;'  _;'_;'_ !  /!  ;`ヽ,ヽ、
  '.、  .;'   ', i ´ハ_」_/|/ ! メ! ,!ヽ,. ヽ.
    `Y    i Vレ'7´;' ,ハ   レ'_」ソノ., ',   ';
   _ノ     i ,ハ i. '、_ソ    ;',ハY.ノ i   i      C - ``Do more with less.''
   `.>'    (__⊂⊃       '、ソノ!イレ'  ノ         C++ - ``Do less with more.''
   ∠._   ノ  | |、    ,.-┐  ⊂!_)‐''"´      Java - ``Do design patterns with boilerplate.''
     レ'´ヽ、 ! iソ>,、.,,_  _,,. イ |ヽ.     Python - ``Do FIOC with tabs or space.''
         'ァ|  !>;`ヽ、「、,ハ.|  !ヘ)           Lisp - ``Transcend the mortal plane with elegance.''
         / !  !、::ヽ、.,___ノヽ. !  |
       ,:'  `ヽ! ';::::::::ヽ::`'; 'レヘ!
       / _,,. -‐rァ-、::::::::::r‐''i7ヽ、
      ;' ァ'´   i,/ ̄`ヽ;:::`i、,| !  ';
      !     | !_____,r'::::::::|:::「i  i
      `ヽ.    「!::::::::!|--‐-ゝソ   !
        ,.ヘ   ',ゝ、ノ/:::::i:::::::'、.,__ノ
      /:::/`'';ー--‐'/::::::::!::,o-oヽ.
     く:::::::/:::::/ ,.-r'::::::::::::::;::'ニニヽ::;ゝ

Name: Anonymous 2012-06-16 1:01

         , -‐ 、, -─-- 、.,_
        ,.i (:::)!       `ヽ,. -、
       ./ ゝ-‐'     _____  !. (::)
     _,./__,,. -‐ ''"´ ̄ ̄`"'' .、`ヽ,ー:'
  ,. ''"´ /´ / ;'  _;'_;'_ !  /!  ;`ヽ,ヽ、
  '.、  .;'   ', i ´ハ_」_/|/ ! メ! ,!ヽ,. ヽ.
    `Y    i Vレ'7´;' ,ハ   レ'_」ソノ., ',   ';
   _ノ     i ,ハ i. '、_ソ    ;',ハY.ノ i   i      C - ``Do more with less.''
   `.>'    (__⊂⊃       '、ソノ!イレ'  ノ       C++ - ``Do less with more.''
   ∠._   ノ  | |、    ,.-┐  ⊂!_)‐''"´     Java - ``Do design patterns with boilerplate.''
     レ'´ヽ、 ! iソ>,、.,,_  _,,. イ |ヽ.      Python - ``Do FIOC with tabs or space.''
         'ァ|  !>;`ヽ、「、,ハ.|  !ヘ)          Lisp - ``Transcend the mortal plane with elegance.''
         / !  !、::ヽ、.,___ノヽ. !  |
       ,:'  `ヽ! ';::::::::ヽ::`'; 'レヘ!
       / _,,. -‐rァ-、::::::::::r‐''i7ヽ、
      ;' ァ'´   i,/ ̄`ヽ;:::`i、,| !  ';
      !     | !_____,r'::::::::|:::「i  i
      `ヽ.    「!::::::::!|--‐-ゝソ   !
        ,.ヘ   ',ゝ、ノ/:::::i:::::::'、.,__ノ
      /:::/`'';ー--‐'/::::::::!::,o-oヽ.
     く:::::::/:::::/ ,.-r'::::::::::::::;::'ニニヽ::;ゝ

Name: Anonymous 2012-06-16 1:01

         , -‐ 、, -─-- 、.,_
        ,.i (:::)!       `ヽ,. -、
       ./ ゝ-‐'     _____  !. (::)
     _,./__,,. -‐ ''"´ ̄ ̄`"'' .、`ヽ,ー:'
  ,. ''"´ /´ / ;'  _;'_;'_ !  /!  ;`ヽ,ヽ、
  '.、  .;'   ', i ´ハ_」_/|/ ! メ! ,!ヽ,. ヽ.
    `Y    i Vレ'7´;' ,ハ   レ'_」ソノ., ',   ';
   _ノ     i ,ハ i. '、_ソ    ;',ハY.ノ i   i      C - ``Do more with less.''
   `.>'    (__⊂⊃       '、ソノ!イレ'  ノ     C++ - ``Do less with more.''
   ∠._   ノ  | |、    ,.-┐  ⊂!_)‐''"´     Java - ``Do design patterns with boilerplate.''
     レ'´ヽ、 ! iソ>,、.,,_  _,,. イ |ヽ.      Python - ``Do FIOC with tabs or space.''
         'ァ|  !>;`ヽ、「、,ハ.|  !ヘ)          Lisp - ``Transcend the mortal plane with elegance.''
         / !  !、::ヽ、.,___ノヽ. !  |
       ,:'  `ヽ! ';::::::::ヽ::`'; 'レヘ!
       / _,,. -‐rァ-、::::::::::r‐''i7ヽ、
      ;' ァ'´   i,/ ̄`ヽ;:::`i、,| !  ';
      !     | !_____,r'::::::::|:::「i  i
      `ヽ.    「!::::::::!|--‐-ゝソ   !
        ,.ヘ   ',ゝ、ノ/:::::i:::::::'、.,__ノ
      /:::/`'';ー--‐'/::::::::!::,o-oヽ.
     く:::::::/:::::/ ,.-r'::::::::::::::;::'ニニヽ::;ゝ

Name: Anonymous 2012-06-16 1:01

         , -‐ 、, -─-- 、.,_
        ,.i (:::)!       `ヽ,. -、
       ./ ゝ-‐'     _____  !. (::)
     _,./__,,. -‐ ''"´ ̄ ̄`"'' .、`ヽ,ー:'
  ,. ''"´ /´ / ;'  _;'_;'_ !  /!  ;`ヽ,ヽ、
  '.、  .;'   ', i ´ハ_」_/|/ ! メ! ,!ヽ,. ヽ.
    `Y    i Vレ'7´;' ,ハ   レ'_」ソノ., ',   ';
   _ノ     i ,ハ i. '、_ソ    ;',ハY.ノ i   i      C - ``Do more with less.''
   `.>'    (__⊂⊃       '、ソノ!イレ'  ノ    C++ - ``Do less with more.''
   ∠._   ノ  | |、    ,.-┐  ⊂!_)‐''"´     Java - ``Do design patterns with boilerplate.''
     レ'´ヽ、 ! iソ>,、.,,_  _,,. イ |ヽ.      Python - ``Do FIOC with tabs or space.''
         'ァ|  !>;`ヽ、「、,ハ.|  !ヘ)          Lisp - ``Transcend the mortal plane with elegance.''
         / !  !、::ヽ、.,___ノヽ. !  |
       ,:'  `ヽ! ';::::::::ヽ::`'; 'レヘ!
       / _,,. -‐rァ-、::::::::::r‐''i7ヽ、
      ;' ァ'´   i,/ ̄`ヽ;:::`i、,| !  ';
      !     | !_____,r'::::::::|:::「i  i
      `ヽ.    「!::::::::!|--‐-ゝソ   !
        ,.ヘ   ',ゝ、ノ/:::::i:::::::'、.,__ノ
      /:::/`'';ー--‐'/::::::::!::,o-oヽ.
     く:::::::/:::::/ ,.-r'::::::::::::::;::'ニニヽ::;ゝ

Name: Anonymous 2012-06-16 1:02

         , -‐ 、, -─-- 、.,_
        ,.i (:::)!       `ヽ,. -、
       ./ ゝ-‐'     _____  !. (::)
     _,./__,,. -‐ ''"´ ̄ ̄`"'' .、`ヽ,ー:'
  ,. ''"´ /´ / ;'  _;'_;'_ !  /!  ;`ヽ,ヽ、
  '.、  .;'   ', i ´ハ_」_/|/ ! メ! ,!ヽ,. ヽ.
    `Y    i Vレ'7´;' ,ハ   レ'_」ソノ., ',   ';
   _ノ     i ,ハ i. '、_ソ    ;',ハY.ノ i   i      C - ``Do more with less.''
   `.>'    (__⊂⊃       '、ソノ!イレ'  ノ    C++ - ``Do less with more.''
   ∠._   ノ  | |、    ,.-┐  ⊂!_)‐''"´     Java - ``Do design patterns with boilerplate.''
     レ'´ヽ、 ! iソ>,、.,,_  _,,. イ |ヽ.       Python - ``Do FIOC with tabs or space.''
         'ァ|  !>;`ヽ、「、,ハ.|  !ヘ)          Lisp - ``Transcend the mortal plane with elegance.''
         / !  !、::ヽ、.,___ノヽ. !  |
       ,:'  `ヽ! ';::::::::ヽ::`'; 'レヘ!
       / _,,. -‐rァ-、::::::::::r‐''i7ヽ、
      ;' ァ'´   i,/ ̄`ヽ;:::`i、,| !  ';
      !     | !_____,r'::::::::|:::「i  i
      `ヽ.    「!::::::::!|--‐-ゝソ   !
        ,.ヘ   ',ゝ、ノ/:::::i:::::::'、.,__ノ
      /:::/`'';ー--‐'/::::::::!::,o-oヽ.
     く:::::::/:::::/ ,.-r'::::::::::::::;::'ニニヽ::;ゝ

Don't change these.
Name: Email:
Entire Thread Thread List