Hi..

can anyone understand this piece of flowchart,i dont understand.
the flow cart is in the attachment.

and below is my source code implementation

input int n;
int i=0,a,b;
if(n>0){
   while(i<a){
       if(n>i){
           if(n>a){
	           if(b>a) b=1;
           }else{
	           n=a;
	           if(n*b >i) b=1;
           }
       }else{
	   n=1;
       }	
   i++;
   }
}

i dont know if it is true, i dont understand for the first if
if its false how i want to proceed it??
can anyone tell me how the first if must be if it is false

Attachments flowchart.jpg 29.76 KB

Inside hexagon is "i=20". You interpret this as while(i<a){} loop.
OK, I can consider with this assumption.

i dont know if it is true, i dont understand for the first if
if its false how i want to proceed it??
can anyone tell me how the first if must be if it is false

You can join two conditions:
if(n>0) -with- while(i<a){} using && logical AND operator
result:
while(i<a && n>0){}
It a little change a diagram, it is not always recommended.
I can not guarantee the accuracy of the given code:

public class Pigmario {

    static int b;
    static int n;
    static int a;
    static int i;

    static void aaa() {
        System.out.println("BEGIN");
        //INPUT n
        n = 10;
        i = 0;
        a = 20;
        b = 0;
        A();
        dump();
    }

    private static void A() {
        System.out.println("A");
        if (n > 0) {
            B();
        } else {
            C();
        }
    }

    private static void B() {
        System.out.println("B");
        while (i < a) {
            C();
        }
    }

    private static void C() {
        System.out.println("C");
        if (n > 1) {
            L();
        } else {
            D();
        }
    }

    private static void D() {
        System.out.println("D");
        n = 1;
        E();
    }

    private static void E() {
        System.out.println("E");
        if (i > a) {
            K();
        } else {
            F();
        }
    }

    private static void F() {
        System.out.println("F");
        i = i + 1;
        B();
    }

    private static void G() {
        System.out.println("G");
        if (b > a) {
            J();
        } else {
            B();
        }
    }

    private static void H() {
        System.out.println("H");
        n = a;
        I();
    }

    private static void I() {
        System.out.println("I");
        if (n * a > i) {
            J();
        } else {
            E();
        }
    }

    private static void J() {
        System.out.println("J");
        b = i;
        K();
    }

    private static void K() {
        System.out.println("K");
        dump();
        System.out.println("END");
        System.exit(0);
    }

    private static void L() {
        System.out.println("L");
        if (n > a) {
            G();
        } else {
            H();
        }
    }

    private static void dump() {
        System.out.println("===");
        System.out.println(a);
        System.out.println(b);
        System.out.println(n);
        System.out.println(i);
    }

    static void uuu() {
        n = 30;
        i = 0;
        a = 20;
        b = 0;
        System.out.println("A");
        //B
        while (i < a && n > 0) {
            //C  //B
            System.out.println("C,B");
            if (n > i) {
                //L
                System.out.println("L");
                if (n > a) {
                    //G
                    System.out.println("G");
                    if (b > a) {
                        //J
                        System.out.println("J");
                        b = 1;
                        //K ??
                        System.out.println("K1");
                        dump();
                        System.exit(1);
                    } else {
                        System.out.println("return to C");
                        continue;
                        //C
                    }
                } else {
                    //H
                    System.out.println("H");
                    n = a;
                    //I
                    System.out.println("I");
                    if (n * a > i) {//if (n * b > i)
                        //J
                        System.out.println("J");
                        b = i;//b = 1
                        //K ??
                        System.out.println("K2");
                        dump();
                        System.exit(2);
                    }
                }
            } else {
                //D
                System.out.println("D");
                n = 1;
                //E ?? LOST
                if (i > a) {
                    // K ??
                    System.out.println("K3");
                    dump();
                    System.exit(3);
                }
            }
            //F
            System.out.println("F");
            i++;
            System.out.println("return to B");
            //B
        }
        System.out.println("K0");
        dump();
        System.exit(0);
    }

    public static void main(String[] args) {
        // aaa();
        uuu();
    }
}

thx
but the sourcecode for the flowchart is just a single method.
....my problem is how the first "if" can be implement in the source code if it is false.

here is how i would solve this

int n=0,i=0,b=0,a=0;
boolean flag=false;
// read n 

if(n>0){
      flag=true;
}

while(1){
if(flag==true)i=20;

if(n>1)
{
    if(n>a){
            if(b>a){
                   b=i;
                   break;
                   }
             else{
                 flag=true;
                 continue;
                 }

           }
          else{
              n=a;
                    if(n*a>i){
                             b=i;
                             break;
                             }
                     else{
                         if(i>a)break;
                         else{
                             i=i+1;
                             flag=true;
                             continue;
                              }
                         }
              }
else{
      n=1;
      if(i>a)break;
      else{
           i=i+1;
           flag=true;
           continue;
           }
}

}

}
This article has been dead for over six months. Start a new discussion instead.