我需要将二进制数字逻辑添加到此代码段中。我只是不能换我周围的头如何实现二进制数,我可以只添加0
S和1
秒,但似乎并没有被正确如何在C中打印二进制数字的三角形#
namespace Star_Pyramid
{
class Program
{
static void Main(string[] args)
{
int num;
Console.WriteLine("enter level");
num = Int32.Parse(Console.ReadLine());
int count = 1;
for (int lines = num; lines >= 1; lines--)
{
for (int spaces = lines - 1; spaces >= 1; spaces--)
{
Console.Write(" ");
}
for (int star = 1; star <= count; star++)
{
Console.Write("*");
Console.Write(" ");
}
count++;
Console.WriteLine();
}
Console.ReadLine();
}
}
}
请解释你的意思是“添加二进制数逻辑” –
@SamiKuhmonen我需要打印由二进制数组成的三角形 –
@MohammadQasim第一个内部'for'可以替换为'Console.Write(new String ('',lines - 1));' –