if(x==y)
break;
for(int i=0;i<7;i++){
for(int j=0;j<7;j++){
if(i+j==6 || i==j){
Console.Write("O");
}else{
Console.Write(".");
}
}
Console.WriteLine("");
}
static void Main(string[] args) { for (int y = 1; y <= 7; y++) { for (int x = 1; x <= y; x++) { Console.Write(x); } Console.WriteLine();//换行 } }
第二个循环中间判断条件改成x<=y就可以了
using System; using System.Collections.Generic; using System.Text;namespace Test{ class Program { static void Main(string[] args) { for (int y = 1; y <= 7; y++) { for (int x = 1; x <= y; x++) { Console.Write(x); } Console.WriteLine();//换行 } } }}