C
C#2y ago
Melio

❔ 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)
17 Replies
Melio
MelioOP2y ago
C#
Thinker
Thinker2y ago
What do you have so far?
Melio
MelioOP2y ago
I'm rn trying to learn logic behind it I don't really know where to start
Thinker
Thinker2y ago
Step 1: Do you know how to write to the console?
Melio
MelioOP2y ago
Yes I know
Thinker
Thinker2y ago
Nice. Do you know how loops work?
Melio
MelioOP2y ago
yes
Melio
MelioOP2y ago
Melio
MelioOP2y ago
That's all what I have rn
canton7
canton72y ago
Maybe start with the code to do the --+--+-- line? Make that work as you vary N. Then move onto one of the other lines -- the | |. Get that working
Melio
MelioOP2y ago
okay I will try
canton7
canton72y ago
Then start putting it together -- do the right number of | | lines, then a --+--+-- line, etc But, break the problem down into smaller problems, and solve those individually first
Melio
MelioOP2y ago
@canton7 thanks for help I done that
Melio
MelioOP2y ago
Melio
MelioOP2y ago
kaktuslove I will try second one
canton7
canton72y ago
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();
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();
Console.Write(new string('-', n);
Console.Write("+");
Console.Write(new string('-', n);
Console.Write("+");
Console.Write(new string('-', n);
Console.WriteLine();
(for the --+--+-- lines) But yours looks like a sensible approach
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server