Menampilkan Perulangan Karakter Membentuk Belah Ketupat C# Posted by Unknown on January 13, 2015 Get link Facebook X Pinterest Email Other Apps using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MODUL3_9 { class Program { static void Main(string[] args) { string A; int n, i, j, k; Console.Write("Input 1 karakter\t="); A = Console.ReadLine(); Console.Write("jumlah tingkatan ="); n = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\n"); for (i = n; i >= 1; i--) { for (j = 1; j <= i; j++) { Console.Write("{0}", A); } for (k = i; k < n; k++) { Console.Write(" "); } for (k = i; k < n; k++) { Console.Write(" "); } //bintang kedua for (j = 1; j <= i; j++) { Console.Write("{0}", A); } Console.Write("\n"); } for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { Console.Write("{0}", A); } for (k = i; k < n; k++) { Console.Write(" "); } for (k = i; k < n; k++) { Console.Write(" "); } for (j = 1; j <= i; j++) { Console.Write("{0}", A); } Console.Write("\n"); } Console.ReadKey(); } } } Comments
Comments
Post a Comment