Print the positive/inverted triangle and the triangle
Package com. demo1; /*** print the positive/inverted triangle ** @ author denny the positive triangle changes the initialization value. The triangle changes the cycle condition. */public class Demo6 {public static void main (String [] args) {print (5); // inverted right triangle printzhen (4); // right triangle printZhenDenng (5); // positive waist triangle printDaoDenng (5 ); // inverted waist triangle} // inverted right triangle public static void print (int row) {System. out. println ("=========== inverted right triangle ======="); for (int x = 0; x <row; x ++) {for (int y = x + 1; y <row; y ++) {System. out. print ("*");} System. out. println () ;}}// public static void printzhen (int row) {System. out. println ("=========== normal right triangle ==============="); for (int x = 0; x <row; x ++) {for (int y = 0; y <= x; y ++) {System. out. print ("*");} System. out. println () ;}}// regular waist triangle public static void printZhenDenng (int row) {System. out. println ("=========== regular waist triangle =============="); for (int x = 0; x <row; x ++) {// control how many rows are displayed // control how many spaces are displayed for (int y = x + 1; y <row; y ++) {System. out. print ("") ;}// control how many digits are displayed for (int z = 0; z <= x; z ++) {System. out. print ("*");} System. out. println () ;}}// inverted waist triangle public static void printDaoDenng (int row) {System. out. println ("=========== waist triangle ============="); for (int x = 0; x <row; x ++) {// control how many rows are displayed // control how many spaces are displayed for (int y = 0; y <x; y ++) {System. out. print ("") ;}// control the number of * numbers displayed for (int z = x; z <row; z ++) {System. out. print ("*");} System. out. println ();}}}
============== Inverted right triangle =========********** ======== positive right Triangle ================*********** ========== regular waist triangle ==== ==========***************** ========== waist triangle ==== ======== ***************