[Homework] Problem 8. Isosceles Triangle 3. Primitive-Data-Types-and-Variables-Homework
Write a program that prints an isosceles triangle of 9 copyright symbols ©, something like this:
© © © © © © © © © |
Note that the © symbol may be displayed incorrectly at the console so you may need to change the console character encoding to UTF-8 and assign a Unicode-friendly font in the console. Note also, that under old versions of Windows the © symbol may still be displayed incorrectly, regardless of how much effort you put to fix it. Това е ословието.
Ето до къде съм стигнал:
using System;
namespace Problem_8.Isosceles_Triangle
{
class Program
{
static void Main()
{
int spaces = 4;
int Az = 1;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < spaces; j++)
{
Console.WriteLine(" ");
}
for (int j = 0; j < Az; j++)
{
Console.Write("© ");
}
Console.WriteLine();
Az++;
spaces--;
}
}
}
}
Като пусна програмата не работи както трябва и не знам защо. Ако може някой може да ми каже къде е проблема ще съм много благодарен.
int c = 0x00a9;
char symbol = (char)c;
Console.WriteLine((" {0}").PadLeft(38), symbol);
Console.WriteLine((" {0} {0}").PadLeft(41), symbol);
Console.WriteLine((" {0} {0}").PadLeft(42), symbol);
Console.WriteLine(("{0} {0} {0} {0}").PadLeft(47), symbol);
Console.WriteLine();
Мерси стана.
using System;
class Triangle
{
static void Main()
{
int spaces = 4;
int copyright = 1;
int numsymbols = 4;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < spaces; j++)
{
Console.Write(" ");
}
for (int j = 0; j < copyright; j++)
{
if (2 < copyright && copyright < numsymbols)
{
if (0 < j && j < (copyright-1))
{
Console.Write(" ");
}
else
{
Console.Write("© ");
}
}
else
{
Console.Write("© ");
}
}
Console.WriteLine();
copyright++;
spaces--;
}
}
}