..... //前面控制输入的X为1-10 for(int i=0;i<x;i++) { int k=1; do {int m=0; for(int p=1;p<=k;p++) {for(int t=1;t<=p;t++) {m=m+1; //这里输出m; } //这里输出一个换行}k++; }while(k!=x+1) }
using System; using System.Collections.Generic; using System.Text;namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int x; x=Console.Read(); try { x = Convert.ToInt32(((char)x).ToString()); } catch { x = 0; } if (x < 1 || x > 10) { Console.Write("invalid argument"); Console.Read(); Console.Read(); Console.Read(); return; } int val=1; //要打印的数 int line = 0; //控制行 for (line = 1; line <= x; line++) { //第i 行有i 个数 for (int i = 0; i < line; i++) { Console.Write(val); Console.Write(" "); val++; } Console.Write("\n"); } Console.Read(); Console.Read(); Console.Read(); } } }
//前面控制输入的X为1-10
for(int i=0;i<x;i++)
{ int k=1;
do
{int m=0;
for(int p=1;p<=k;p++)
{for(int t=1;t<=p;t++)
{m=m+1;
//这里输出m; }
//这里输出一个换行}k++;
}while(k!=x+1)
}
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x;
x=Console.Read();
try
{
x = Convert.ToInt32(((char)x).ToString());
}
catch
{
x = 0;
} if (x < 1 || x > 10)
{
Console.Write("invalid argument");
Console.Read();
Console.Read();
Console.Read();
return;
} int val=1; //要打印的数
int line = 0; //控制行 for (line = 1; line <= x; line++)
{
//第i 行有i 个数
for (int i = 0; i < line; i++)
{
Console.Write(val);
Console.Write(" ");
val++;
}
Console.Write("\n");
} Console.Read();
Console.Read();
Console.Read();
}
}
}