+ 1
Suggestions please! Write a program to print a figure in the shape of a heart by the sign "o"?
I'm somewhere, using a number of nested loops in C# but I'm far from what I wanted. I need help with any programming language or even for suggestions on how it can be solved
3 Respuestas
+ 5
https://code.sololearn.com/cAa4DQ554Ddj/?ref=app
... design is the main stuff, coding it with loops is just technics ;P
+ 2
Don't know too much of C#, but in Python it can be achieved by sth like this:
https://www.instagram.com/p/BSq4wflhcvl/
💟💗💝🖤💜💛💚💙💖❤️💓
(formula inside)
+ 1
This is the Easiest way, IMO
Go on some 2d pixelated text art site or image to get the outline of a simple heart.
Now, each pixel that is not what you want is false. Each pixel you want is true.
Store it in a boolean array, can be one dimensional.
Use a for loop to itterate over the array, if it's true draw an "o", else draw a space.
Super simple way to draw anything you want in the console, assuming it's not to large. If it's to large, then yeah it might be to much work.
You could use SpriteCraft.
* You could use a byte or int array if you're lazy and don't want to have to write "false" or "true" a bunch.
To be honest I'm not sure how this method will look for some things though, since it's just the console. Spaces may not be the same width as the character you choose.
Here's a quick pic of some emoji guy with glasses I quickly did in a few mins using this trick:
https://code.sololearn.com/cM75IkMnL8fM/#java
Or
You could stick with the double for loops and try some more math intensive way.
For example/
Each column is thinner than the one before. That means you could do something like: Width-i; (I's where you place an "o".). This would only be applied after the c column. x could be 5 or 3, whatever you want.
Assuming width is the largest width spot of the heart, and i is the for loop for the current column you are on.