1 //1、用户输入姓名,然后打印此人的年龄,从1岁-18岁,每一岁占一行, 2 //打印内容为“我今年xxx岁了!”; 3 //当6岁时增加打印“我上小学了!”; 4 //当11岁时增加打印“我上初中了!”; 5 //当15岁时增加打印“我上高中了!”; 6 //当18岁时增加打印“我成年了!考上了北大!”; 7 8 Console.Write("输入姓名"); 9 Console.ReadLine(); 10 11 for (int a = 1; a <= 18; a++) 12 { 13 if (a == 6) 14 { 15 Console.WriteLine("我今年" + a + "岁了,我上小学了!"); 16 17 } 18 else if (a == 11) 19 { 20 Console.WriteLine("我今年" + a + "岁了,我上初中了!"); 21 } 22 else if (a == 15) 23 { 24 Console.WriteLine("我今年" + a + "岁了,我上高中了!"); 25 } 26 else if (a == 18) 27 { 28 Console.WriteLine("我今年" + a + "岁了,我成年了!考上了北大!"); 29 } 30 else 31 { 32 Console.WriteLine("我今年" + a + "岁了"); 33 34 } 35 } 36 37 38 Console.ReadLine();