试着编一程序,显示如下数字金字塔:
1
121
12321
1234321
123454321
1234564321
1234567654321
123456787654321
12345678987654321
费了我好久,没一点思路,大家帮帮忙呗,谢谢了!
1
121
12321
1234321
123454321
1234564321
1234567654321
123456787654321
12345678987654321
费了我好久,没一点思路,大家帮帮忙呗,谢谢了!
调试欢乐多
{
if (index == count)
Console.WriteLine("{0}{1}{2}", left, index, right);
else
{
Print(string.Format("{0," + (count - index) + "}{1}", "", left),
right, index, index);
Print(left + index, index + right, index + 1, count);
Print(string.Format("{0," + (count - index) + "}{1}", "", left),
right, index, index);
}
}
Print("", "", 1, 7);
for(int i=1;i<10;i++)
{
for(int m=0;m<i;m++)
{
Console.Write(i);
}
Console.WriteLine();
for(int n=i-1;n>0;n--)
{
Console.WriteLine(n);
}
Console.WriteLine();}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
F1_1(5);
} static public void F1_1(uint I)
{
for (int x = 1; x < (2 * I - 1); x++)
{
Console.WriteLine(new string('*', (int)(2 * x - 1)));
} Console.ReadKey();
}
}
}
看了一下,还是有错... class Program
{
static void Main(string[] args)
{
for (int i = 1; i < 10; i++)
{
for (int m = 1; m <= i; m++)
{
Console.Write(m);
}
for (int n = i - 1; n> 0; n--)
{
Console.Write(n);
}
Console.WriteLine();
}
Console.ReadLine();
}
应该这样
class Program
{
static void Main(string[] args)
{
for (int i = 1; i < 10; i++)
{
for (int m = 1; m <= i; m++)
{
Console.Write(m);
}
for (int n = i - 1; n> 0; n--)
{
Console.Write(n);
}
Console.WriteLine();
}
Console.ReadLine();
}
11 * 11 = 121
111 * 111 = 12321
...so
int a = 1;
for (int i = 1; i <= 9; i++)
{
printf(a * a);
a = a * 10 + 1;
}
for(int i=1;i<=9;i++)
{
for(int a=1;a<=i;a++,)
{ array[n]=a; n++;}
for(int b=i-1;b>=1;b--)
{ array[n]=b; n++;}
}
{
for (int i = 1; i < 10; i++)
{
string str = "";
for (int n = 1; n <= i; n++)
{
str = str + n.ToString();
}
for (int m = i; m-1 > 0; m--)
{
str = str + Convert.ToString(m - 1);
}
MessageBox.Show(str);
}
}
{
for (int i = 1; i < 10; i++)
{
string str = "";
for (int n = 1; n <= i; n++)
{
str = str + n.ToString();
}
for (int m = i; m-1 > 0; m--)
{
str = str + Convert.ToString(m - 1);
}
MessageBox.Show(str);
}
}