C#
C#

help

Root Question Message

Melio
Melio1/9/2023
Unicode Art

Ask the user for an unsigned integer N. Then, create Unicode-Art as an M by M grid, where M = 3*N+2, consisting of spaces and the characters |, -, and +; N is the number of lines/characters between intersections, i.e. + signs.
It should return something like this: (image)
Melio
Melio1/9/2023
C#
thinker227
thinker2271/9/2023
What do you have so far?
Melio
Melio1/9/2023
I'm rn trying to learn logic behind it
Melio
Melio1/9/2023
I don't really know where to start
thinker227
thinker2271/9/2023
Step 1: Do you know how to write to the console?
Melio
Melio1/9/2023
Yes I know
thinker227
thinker2271/9/2023
Nice. Do you know how loops work?
Melio
Melio1/9/2023
yes
Melio
Melio1/9/2023
Melio
Melio1/9/2023
That's all what I have
Melio
Melio1/9/2023
rn
canton7
canton71/9/2023
Maybe start with the code to do the --+--+-- line? Make that work as you vary N.
canton7
canton71/9/2023
Then move onto one of the other lines -- the | |. Get that working
Melio
Melio1/9/2023
okay I will try
canton7
canton71/9/2023
Then start putting it together -- do the right number of | | lines, then a --+--+-- line, etc
canton7
canton71/9/2023
But, break the problem down into smaller problems, and solve those individually first
Melio
Melio1/9/2023
@660066004059029524 thanks for help I done that
Melio
Melio1/9/2023
Melio
Melio1/9/2023
:kaktuslove:
Melio
Melio1/9/2023
Now I will try second one
canton7
canton71/9/2023
FWIW, I'd have probably written something like:

for (int i = 0; i < n; i++)
{
    Console.Write("-");
}
Console.WriteLine("+");
for (int i = 0; i < n; i++)
{
    Console.Write("-");
}
Console.WriteLine("+");
for (int i = 0; i < n; i++)
{
    Console.Write("-");
}
Console.WriteLine();

Or:
Console.Write(new string('-', n);
Console.Write("+");
Console.Write(new string('-', n);
Console.Write("+");
Console.Write(new string('-', n);
Console.WriteLine();
canton7
canton71/9/2023
(for the --+--+-- lines)
canton7
canton71/9/2023
But yours looks like a sensible approach
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy