例如1 22 33 444 555 666 7777 8888 9999 101011010 1111111111 1212121212 1313131313 1414141414 1515151515 1616161616......
------解决方案--------------------------------------------------------
- SQL code
--定义参数declare @n bigint;set @n=20declare @i bigint;set @i=1declare @j bigint;declare @k bigint;--定义个表存放结果declare @table table(id bigint)while (@i<=@n) begin set @j=0;set @k=0 while @j<@i begin set @j=@j+@k;set @k=@k+1 end insert into @table select replicate(@i,@k-1) set @i=@i+1 end--查看结果select * from @table/*122334445556667777888899991010101011111111111212121212131313131314141414141515151515161616161616171717171717181818181818191919191919202020202020*/
------解决方案--------------------------------------------------------
- C# code
public static void Out(int n) { for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { int num = 1; while (num <= i) { Console.Write((i - 1) * i / 2 + 1 + j); num++; } Console.Write(" "); } Console.WriteLine(); } }