0-1 Triangle Pattern Java Programming Code

 Zero One Triangle Pattern 



0-1 Triangle Pattern Java Programming Code:

public class ZeroOne {
    public static void zero_one_triangle(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                if ((i + j) % 2 == 0) { // even
                    System.out.print("1");
                } else {
                    System.out.print("0");
                }
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        zero_one_triangle(7);
    }
}

...

Floyd's Triangle Pattern Simple Java Programming Code


Floyd's Triangle Pattern Output:


Floyd's Triangle Pattern Java Code:

public class FloydsTrianglePattern {
    public static void floyds_triangle(int n) {
        // outer
        int counter = 1;
        for (int i = 1; i <= n; i++) {
            // inner - how many times will counter be printed
            for (int j = 1; j <= i; j++) {
                System.out.print(counter + " ");
                counter++;
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        floyds_triangle(9);

    }
}


Inverted Half Pyramid with Numbers Pattern Java Programming Code

Inverted Half Pyramid with Numbers Output Screenshot



Inverted Half Pyramid with Numbers Pattern Simple Java Code

public class Inverted_Half_Pyramid_with_Numbers {
    public static void main(String[] args) {
        IHPN(9);

    }

    public static void IHPN(int n) {
        for (int i = 1; i <= n; i++) {
            // inner - numbers
            for (int j = 1; j <= n - i + 1; j++) {
                System.out.print(j);
                // System.out.print(j + " ");
            }
            System.out.println();
        }
    }
}

Inverted And Rotated Half Pyramid Java Programming Pattern Code


Inverted And Rotated Half Pyramid Pattern Output Result Image Screenshot.





Code:

public class Inverted_Rotated_Half_Pyramid {
    public static void irhp(int n) {
        // outer
        for (int i = 1; i <= n; i++) {
            // spaces
            for (int j = 1; j <= n; j++) {
                System.out.print(" ");
            }
            // stars
            for (int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        irhp(7);

    }
}

sgd

Hollow Rectangle Pattern Java Programming Code

Hollow Rectangle Pattern Java Programming Code Output:


Hollow Rectangle Pattern Simple Java Code:


public class HollowRectanglePattern {
    public static void hollow_rectangle(int totRows, int totCols) {
        // outer Loop
        for (int i = 1; i <= totRows; i++) {
            // inner - columns
            for (int j = 1; j <= totCols; j++) {
                // cell = (i,j)
                if (i == 1 || i == totRows || j == 1 || j == totCols) {
                    // boundary cells
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }

    }

    public static void main(String[] args) {
        hollow_rectangle(10, 15);
    }
}


Please Don't Received Call of Your Enemy. They hell Your life. Please Block then as soon as possible.

Noman, Nishan, Maruf, Amir, Samia Batch of 18 CSE in PCIU students are always disturbing me, without any reason They are very jealous of me, envy me and gossip about me all day long.

They abuse me all the time. I feel very sad about it. 

Max Sub Array Sum: Kadane's Algorithm

Code of: Max Sub Array Sum: Kadane's Algorithm. public class MaxSubArraySumKadanesALgorithm {     public static void Kadane ( int ...