1.输出九九乘法表
1 //99乘法口诀表 :矩形 2 for (int i = 1; i < 10; i++) 3 { 4 for (int j = 1; j <=9; j++) 5 { 6 Console.Write("{0}*{1}={2} ",i,j,i*j);//占位符 7 } 8 Console.WriteLine();//换行 9 } 10 //三角形 11 for (int i = 1; i < 10; i++) 12 { 13 for (int j = 1; j <= i; j++) 14 { 15 Console.Write("{0}*{1}={2} ", i, j, i * j);//占位符 16 } 17 Console.WriteLine();//换行 18 }
输出简单图形练习
1 //输出 2 ///****** 3 ///****** 4 ///****** 5 ///****** 6 for (int i = 0; i < 5; i++) 7 { 8 for (int j = 0; j < 8; j++) 9 { 10 Console.Write("*"); 11 } 12 Console.WriteLine(); 13 } 14 15 ///* 16 ///** 17 ///*** 18 ///**** 19 ///***** 20 for (int i = 0; i < 5; i++) 21 { 22 for (int j = 0; j <= i; j++) 23 { 24 Console.Write("*"); 25 } 26 Console.WriteLine(); 27 } 28 29 ///***** 30 ///**** 31 ///*** 32 ///** 33 ///* 34 for (int i = 5 - 1; i >= 0; i--) 35 { 36 for (int j = 0; j < i; j++) 37 { 38 Console.Write("*"); 39 } 40 Console.WriteLine(); 41 } 42 43 ///***** 44 ///* * 45 ///* * 46 ///* * 47 ///***** 48 for (int i = 0; i < 5; i++) 49 { 50 for (int j = 0; j < 5; j++) 51 { 52 if ((i !=0 && i != 4 ) && (j != 0 && j != 4)) 53 { 54 Console.Write("口"); 55 continue; 56 } 57 Console.Write("我"); 58 } 59 Console.WriteLine(); 60 } 61 62 63 ///12345 64 ///1234 65 ///123 66 ///12 67 ///1 68 for (int i = 5; i >= 1; i--) 69 { 70 for (int j = 1; j <= i; j++) 71 { 72 Console.Write(j); 73 } 74 Console.WriteLine(); 75 }