Use a few exercises to demonstrate the nesting of the For loop
1. Print to form
★
★
¡ï ★
★★★★
★★★★★
namespaceNesting of _2017_2_24_for loops {classProgram {Static voidMain (string[] args) {Console.WriteLine ("Please enter a number:"); intA=Convert.ToInt32 (Console.ReadLine ()); for(inti =1; I <= a;i++ ) { for(intb =1; b <= i;b++) {Console.Write ("★"); } console.write ("\ n"); } console.readline (); } }}
★★★★★
★★★★
¡ï ★
★
★
namespace_2017_2_24_for Loops of nested _ painted stars 2{classProgram {Static voidMain (string[] args) {Console.WriteLine ("Please enter a number"); intA =Convert.ToInt32 (Console.ReadLine ()); for(intb =1; b <= a;b++ ) { for(intc =a; C >= b;c--) {Console.Write ("★"); } console.write ("\ n"); } console.readline (); } }}
0000★
000★★
00★★★
0★★★★
★★★★★
namespace_2017_2_24_for loop nesting __ stars 3{classProgram {Static voidMain (string[] args) {Console.WriteLine ("Please enter a number"); intCount =Convert.ToInt32 (Console.ReadLine ()); String b=" "; String C ="※"; for(intD =1; D <= Count; d++) { for(intE = count-1; e >= D; e--) {Console.Write (b); } console.write (c); for(intx =0; X < D1; X + +) {Console.Write (c); } console.write ("\ n"); } console.readline (); } }}
★★★★★
★★★★
¡ï ★
★
★
namespace_2017_2_24_for_ Loop _ nesting __ stars 4{classProgram {Static voidMain (string[] args) {Console.WriteLine ("Please enter a number:"); intA=Convert.ToInt32 (Console.ReadLine ()); String b=" "; String c="☆"; for(intD =1; D <= A; d++) { for(intE =1; E < d;e++) {Console.Write (b); } for(intf = a-d; F <= a&&f>=0; f--) {Console.Write (c); } console.write ("\ n"); } console.readline (); } }}
★
¡ï ★
★★★★★
★★★★★★★
★★★★★★★★★
★★★★★★★
★★★★★
¡ï ★
★
namespace_2017_2_24__for loop nested ___ Print Diamond {classProgram {Static voidMain (string[] args) {Console.Write ("Please enter a number:"); intA =Convert.ToInt32 (Console.ReadLine ()); String b="0"; String c="★"; for(intD =1; D <= a;d++ ) { for(intE = A-1; e >= D; e--) {Console.Write (b); } for(intf =1; F <= (d *2-1); f++) {Console.Write (c); } console.write ("\ n"); } for(intg =1; G < a;g++ ) { for(inth =1; H <= g;h++) {Console.Write (b); } for(inti =1; I <= ((a-g) *2-1); i++) {Console.Write (c); } console.write ('\ n'); } console.readline (); } }}
2017-2-24 nesting of C # base for loops