输出个数为5的倍数就自动换行,就可以了.
for(int i=1;i<=array.length;i++)
{
if(i%5==0)
{
Console.WriteLine(array[i-1]);
}
else
{
Console.Write(array[i-1]);
}
}
抛砖引玉,期待比这更好的···
int[] temp = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
//循环输出3行
for (int i = 0; i < 3; i++)
{
//循环输出5列
for (int j = 0; j < 5; j++)
{
Response.Write(temp[j +(i*5)]+" ");
}
Response.Write("<br/>");
}