using System; |
namespace 三角数阵2 |
{ |
class Program |
{ |
static void Main( string [] args) |
{ |
Console.Write( "输入三角形边长(字符数):" ); |
int n = int .Parse(Console.ReadLine()); |
Console.WriteLine(); |
Triangle(n); |
Console.ReadLine(); |
} |
public static void Triangle( int n) |
{ |
int a = 0; |
for ( int i=0;i<n;i++) |
{ |
a = (i + 1) * (i + 2) / 2; |
for ( int j = 0; j < n - i; j++) |
{ |
Console.Write( "{0,3}" , a); |
a += i + j + 1; |
} |
Console.WriteLine(); |
} |
} |
} |
} |