Pola piramida angka berongga dengan python
Jalankan
num = 8 k = 0 for i in range(1, num + 1): # printing left spaces in rows for j in range(i, num): print(" ", end="") while k != (2 * i - 1): # printing left/right boundaries if k == 0 or k == 2 * i - 2: print("*", end="") # printing spaces in the middle of the triangle else: print(" ", end="") k = k + 1 k = 0 print() # printing bottom boundary of the triangle for i in range(0, 2 * num - 1): print("*", end="") # # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 * * * * * * * * * * * *20 * * * * * * * * * * * *21 * * * * * * * * * * * *22 * * * * * * * * * * * *23 # # # # # # # # # # # ###########28 * * * * * * * * * * * *25 * * * * * * * * * * * *26 # # # # # # # # # # # ###########28 * * * * * * * * * * * *28________3 Show # # # # # # # # # # # ###########_6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *32 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 * * * * * * * * * * * *35 * * * * * * * * * * * *21 * * * * * * * * * * * *22 * * * * * * * * * * * *38
* * * * * * * * * * * *40 * * * * * * * * * * * *23 * * * * * * * * * * * *42 * * * * * * * * * * * *43 * * * * * * * * * * * *16 * * * * * * * * * * * *45 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *48 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 #include 0 * * * * * * * * * * * *51 * * * * * * * * * * * *16 * * * * * * * * * * * *23 # # # # # # # # # # # ###########49 * * * * * * * * * * * *55 * * * * * * * * * * * *20 * * * * * * * * * * * *57 # # # # # # # # # # # ###########28________3______59 * * * * * * * * * * * *62 * * * * * * * * * * * *16 * * * * * * * * * * * *16 _______________23 * * * * * * * * * * * *____66 ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________g
* * * * * * * * * * * *40 * * * * * * * * * * * *23 * * * * * * * * * * * *79 * * * * * * * * * * * *43 * * * * * * * * * * * *16 * * * * * * * * * * * *45
* * * * * * * * * * * *85
* * * * * * * * * * * *40 * * * * * * * * * * * *23 * * * * * * * * * * * *42 * * * * * * * * * * * *43 * * * * * * * * * * * *16 * * * * * * * * * * * *45
* * * * * * * * * * * *15 * * * * * * * * * * * *16 * * * * * * * * * * * *15________3______26 # # # # # # # # # # # ###########28 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *15 * * * * * * * * * * * *16 # # # # # # # # # # # ###########23________315______4 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *40 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----06 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----07 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----10 # # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 * * * * * * * * * * * *20 * * * * * * * * * * * *21 * * * * * * * * * * * *22 * * * * * * * * * * * *23 # # # # # # # # # # # ###########23 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----18_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ jelas -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *40 * * * * * * * * * * * *23 * * * * * * * * * * * *79 * * * * * * * * * * * *43 * * * * * * * * * * * *16 * * * * * * * * * * * *45
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----_32 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----21 * * * * * * * * * * * *16 # # # # # # # # # # # ###########04 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----_36
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----_37 C#
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----39
# # # # # # # # # # # ###########6 void 5 void 6 void -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----47 # # # # # # # # # # # ###########6 # # # # # # # # # # # ###########5 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########1 # # # # # # # # # # # ###########8 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *0 # # # # # # # # # # # ###########6 * * * * * * * * * * * *1 # # # # # # # # # # # ###########_6 # # # # # # # # # # # ###########6 void 6 void # # # # # # # # # # # ###########0 # # # # # # # # # # # ###########1 * * * * * * * * * * * *5 # # # # # # # # # # # ###########6 # # # # # # # # # # # ###########5 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########1 * * * * * * * * * * * *9 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----2 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----3 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########5
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----7
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 // CPP program to print a hollow pyramid pattern 0
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----81 // CPP program to print a hollow pyramid pattern 3# # # # # # # # # # # ###########2
* * * * * * * * * * * *1
# # # # # # # # # # # ###########_62 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----81 #include 7# # # # # # # # # # # ###########2
# # # # # # # # # # # ###########_62 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----81 // CPP program to print a hollow pyramid pattern 3# # # # # # # # # # # ###########2
* * * * * * * * * * * *1
________315 # # # # # # # # # # # ###########_358_______3
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *1 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 namespace 7-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 std; 0
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----81 #include 7# # # # # # # # # # # ###########2 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *1 # # # # # # # # # # # ###########6 * * * * * * * * * * * *1 * * * * * * * * * * * *1
PHP
# # # # # # # # # # # ###########0 // CPP program to print a hollow pyramid pattern 39# # # # # # # # # # # ###########61 # # # # # # # # # # # ###########_5 # # # # # # # # # # # ###########6 // CPP program to print a hollow pyramid pattern 43 // CPP program to print a hollow pyramid pattern 44# # # # # # # # # # # ###########_6 # # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----3 # # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 * * * * * * * * * * * *23 // CPP program to print a hollow pyramid pattern 51 // CPP program to print a hollow pyramid pattern 52// CPP program to print a hollow pyramid pattern 51 // CPP program to print a hollow pyramid pattern 54// CPP program to print a hollow pyramid pattern 39// CPP program to print a hollow pyramid pattern 4// CPP program to print a hollow pyramid pattern 158_____# # # # # # # # # # # ###########6 # # # # # # # # # # # ###########5 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----7 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 * * * * * * * * * * * *23 // CPP program to print a hollow pyramid pattern 67 * * * * * * * * * * * *16 // CPP program to print a hollow pyramid pattern 51// CPP program to print a hollow pyramid pattern ______________________________________________________________________________________________________________________________________________________________________________________________________________-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########5
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *1 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 // CPP program to print a hollow pyramid pattern 8-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 #include 0 * * * * * * * * * * * *23 // CPP program to print a hollow pyramid pattern 43 // CPP program to print a hollow pyramid pattern 92// CPP program to print a hollow pyramid pattern 51 // CPP program to print a hollow pyramid pattern 94-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########5
* * * * * * * * * * * *23 // CPP program to print a hollow pyramid pattern 43 #include 01// CPP program to print a hollow pyramid pattern 43 #include 03
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *1 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 // CPP program to print a hollow pyramid pattern 43 // CPP program to print a hollow pyramid pattern 44-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 namespace 3-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 // CPP program to print a hollow pyramid pattern 80 #include 30// CPP program to print a hollow pyramid pattern 4# # # # # # # # # # # ###########6 * * * * * * * * * * * *1 # # # # # # # # # # # ###########_6 # # # # # # # # # # # ###########6 namespace 7# # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 * * * * * * * * * * * *23 // CPP program to print a hollow pyramid pattern 51 // CPP program to print a hollow pyramid pattern 44// CPP program to print a hollow pyramid pattern 51 #include 43// CPP program to print a hollow pyramid pattern 39 #include 45// CPP program to print a hollow pyramid pattern 515# # # # # # # # # # # ###########6 # # # # # # # # # # # ###########5 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 // CPP program to print a hollow pyramid pattern 80 #include 7// CPP program to print a hollow pyramid pattern 4# # # # # # # # # # # ###########6 * * * * * * * * * * * *1 * * * * * * * * * * * *1
# # # # # # # # # # # ###########0 // CPP program to print a hollow pyramid pattern 39# # # # # # # # # # # ###########2
Javascript
# # # # # # # # # # # ###########8
* * * * * * * * * * * *0
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----36
# # # # # # # # # # # ###########5 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 #include 69 * * * * * * * * * * * *9 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----2 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----3 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########5
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----7
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 #include 91
# # # # # # # # # # # ###########5
# # # # # # # # # # # ###########2
* * * * * * * * * * * *1
________316 * * * * * * * * * * * *_316_______0 using 05
# # # # # # # # # # # ###########5
________316______5 # # # # # # # # # # # ###########2
# # # # # # # # # # # ###########2
* * * * * * * * * * * *1
# # # # # # # # # # # ###########2 namespace 3-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *1 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 namespace 7-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 using 39-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 # # # # # # # # # # # ###########5
# # # # # # # # # # # ###########2 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----6 * * * * * * * * * * * *1
* * * * * * * * * * * *1
# # # # # # # # # # # ###########_6 using 54Keluaran # # # # # # # # # # # ###########_ Kompleksitas waktu. O(N^2), Algoritma ini memiliki kompleksitas waktu O(N^2), di mana N adalah jumlah baris. Ini karena kita mengulangi baris dan kolom pola, yang membutuhkan waktu O(N^2) untuk menyelesaikannya Kompleksitas ruang. O(1), Algoritma ini tidak memerlukan ruang tambahan, sehingga kompleksitas ruangnya adalah O(1) 2. Berlian Berongga Catatan. Untuk input genap, cetak pola untuk n-1 Contoh Memasukkan. 1 Keluaran Untuk n=1 Memasukkan. 7 Keluaran Untuk n=7 Memasukkan. 9 Keluaran Untuk n=9
Mendekati. Untuk mencetak berlian, kita perlu mencetak spasi sebelum bintang dan setelah bintang untuk mencapai jarak bintang yang terus bertambah Untuk mencetak bentuk kotak kita perlu mencetak '-' untuk i==1 (baris pertama) & i==n (baris terakhir) dan '. ’ untuk j==1 (kolom pertama) dan j==n (kolom terakhir) Algoritma. 1. Jika n adalah kenaikan ganjil n 2. Temukan pertengahan = n/2 3. Lintasi dari 1 hingga pertengahan untuk mencetak separuh atas pola (katakanlah i) 4. Lintasi dari 1 ke mid-i untuk mencetak spasi untuk kotak terluar paling kiri atas (katakanlah j) 5. Jika (i==1) cetak '*' (karena untuk baris pertama kita hanya membutuhkan satu bintang) 6. lain cetak '*' dan lintasi dari 1 ke 2*i-3 untuk mencetak spasi untuk berlian berongga (katakanlah j) dan cetak '*' setelah loop selesai 7. Lintasi dari 1 ke mid-i untuk mencetak spasi lagi untuk kotak terluar paling kanan atas (katakanlah j) 8. Tutup loop pada langkah 3 9. Lintasi dari pertengahan+1 ke n-1 untuk mencetak separuh bawah pola (katakanlah i) 4. Lintasi dari 1 ke i-mid untuk mencetak ruang untuk kotak terluar paling kiri bawah (katakanlah j) 5. Jika (i==n-1) cetak '*' (karena untuk baris terakhir kita hanya membutuhkan satu bintang) 6. lain cetak '*' dan lintasi dari 1 ke 2*(n-i)-3 untuk mencetak spasi untuk berlian berongga (katakanlah j) dan cetak '*' setelah loop selesai 7. Lintasi dari 1 ke i-mid untuk mencetak spasi lagi untuk kotak terluar paling kanan bawah (katakanlah j) 8. Tutup loop pada langkah 9 C++14
# # # # # # # # # # # ###########0 # # # # # # # # # # # ###########1 using 63# # # # # # # # # # # ###########_5 # # # # # # # # # # # ###########6 # # # # # # # # # # # ###########1 using 67# # # # # # # # # # # ###########6 #include 3using 70using 71
# # # # # # # # # # # ###########_6 using 75# # # # # # # # # # # ###########_6 # # # # # # # # # # # ###########_6 using 78# # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 using 81
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 using 84using 85
________316 * * * * * * * * * * * *_316_______3 using 93
* * * * * * * * * * * *1 using 0# # # # # # # # # # # ###########5
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 namespace 09namespace 10
* * * * * * * * * * * *1
* * * * * * * * * * * *1
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 using 84namespace 26
* * * * * * * * * * * *1
________358 * * * * * * * * * * * *_358_______38
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 namespace 41
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 namespace 45using 85
________316 * * * * * * * * * * * *_316_______3 namespace 54
* * * * * * * * * * * *1 using 0# # # # # # # # # # # ###########5
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 namespace 70namespace 10
* * * * * * * * * * * *1
* * * * * * * * * * * *1
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 namespace 45namespace 26
* * * * * * * * * * * *1 * * * * * * * * * * * *1
# # # # # # # # # # # ###########1 std; 00
# # # # # # # # # # # ###########1 std; 03
* * * * * * * * * * * *0 * * * * * * * * * * * *1
Jawa
# # # # # # # # # # # ###########_6
# # # # # # # # # # # ###########0 # # # # # # # # # # # ###########1 * * * * * * * * * * * *5 # # # # # # # # # # # ###########_5 # # # # # # # # # # # ###########6 # # # # # # # # # # # ###########1 using 67# # # # # # # # # # # ###########6 #include 3std; 24# # # # # # # # # # # ###########49 std; _26# # # # # # # # # # # ###########28 # # # # # # # # # # # ###########61 using 71
# # # # # # # # # # # ###########6 std; 33# # # # # # # # # # # ###########49 // CPP program to print a hollow pyramid pattern 4
# # # # # # # # # # # ###########_6 using 78# # # # # # # # # # # ###########6 -----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 # # # # # # # # # # # ###########27 # # # # # # # # # # # ###########28 std; 43
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 std; 46# # # # # # # # # # # ###########28 std; 48using 85
# # # # # # # # # # # ###########39 // CPP program to print a hollow pyramid pattern 3# # # # # # # # # # # ###########2
# # # # # # # # # # # ###########28 std; 59
# # # # # # # # # # # ###########39 using 96# # # # # # # # # # # ###########2
* * * * * * * * * * * *1 using 0# # # # # # # # # # # ###########5
# # # # # # # # # # # ###########39 using 96# # # # # # # # # # # ###########2 namespace 06
-----*----- | * * | | * * | | * * | |* *| * * |* *| | * * | | * * | | * * | -----*-----1 std; 46# # # # # # # # # # # ###########28 std; _77# # # # # # # # # # # ###########49 void 54std; 80std; 81namespace _10
Bagaimana cara mencetak pola bintang piramida terbalik berongga dengan Python?Pola bintang segitiga siku-siku berongga dengan python . Awal Ambil jumlah baris sebagai input dari pengguna dan simpan ke dalam num Jalankan loop 'i' beberapa kali untuk mengulangi semua baris yang Mulai dari i=0 hingga num Jalankan loop bersarang di dalam loop utama untuk ruang pencetakan yang dimulai dari j=0 hingga i Bagaimana Anda membuat pola piramida dengan Python?Kode Sumber . Pertama, kami mendapatkan tinggi baris piramida dari pengguna Di loop pertama, kami beralih dari i = 0 ke i = baris Di loop kedua, kami mencetak angka mulai dari 1 hingga j , di mana j berkisar dari 0 hingga i Setelah setiap iterasi dari loop pertama, kami mencetak baris baru Bagaimana Anda mencetak pola segitiga berongga?scanf("%u",&baris);
Bagaimana Anda mencetak segitiga siku-siku berongga dengan Python?Deskripsi . # Ulangi baris. untuk i dalam rentang(1, n+1) # Ulangi kolom. untuk j dalam rentang(1, n+1) jika (i == j) atau (j == 1) atau (i == n). cetak("*", akhir=" ") kalau tidak. cetak(" ", akhir=" ") |