static void Main(string[] args)
{
int nLine=5; //总行数
int iLine =1; //行计数器
do
{
int iCol = 0; //列计数器
do
{
System.Console.Write(iLine);
iCol++;
} while (iCol < iLine);
System.Console.WriteLine();
iLine++;
} while (iLine <= nLine);
System.Console.ReadLine();
}
for(int i=1;i<=5;i++)
{
int j=0;
while(j!=i)
{
console.write(i)
j++;
}
console.writeLine();
}
//没有编译的
这都不会,这是最最最简单的循环输出,是你老师叫你做的吗》》
for(int i=1;i<=n;i++){
int t=i;
while(i>0){
Console.write(t);
i--;
}
Console.write(" ");
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Output
{
class Program
{
static void Main(string[] args)
{
int [][] array={new int[]{1},
new int[]{2,2},
new int[]{3,3,3},
new int[]{4,4,4,4},
new int[]{5,5,5,5,5}};
foreach(var row in array)
{
foreach(var element in row)
Console.Write("{0}",element);
Console.WriteLine();
}
Console.ReadLine();
}
}
}
还有一种最简单,两个循环
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write("{0}", i);
}
Console.Write("\n");
}
Console.ReadLine();