heart shape in C#

2,257 views
Skip to first unread message

Pablo Vent

unread,
Mar 1, 2015, 3:37:16 PM3/1/15
to introcs...@googlegroups.com
Hi there guys.  I am trying to work out question 190 of chp 2:
Write a program to print a figure in the shape of a heart by the sign "o".  All I can think of to solve this problem is

Console.WriteLine("  oo oo  ");
Console.WriteLine(" ooo ooo ");
Console.WriteLine(" ooooooo ");
Console.WriteLine("  ooooo  ");
Console.WriteLine("   ooo   ");
Console.WriteLine("    o    ");

But of course it looks silly. Any ideas? Thans

anmol...@artesian.io

unread,
Jun 9, 2015, 12:24:27 AM6/9/15
to introcs...@googlegroups.com
 class HeartFromSymbolO
    {
        static void Main()
        {
            char o = 'o';
            Console.WriteLine("  " + o + o + o + "   " + o + o + o);
            Console.WriteLine(" " + o + "   " + o + " " + o + "   " + o);
            Console.WriteLine(o + "     " + o + "     " + o);
            Console.WriteLine(o + "     " + " " + "     " + o);
            Console.WriteLine(o + "     " + " " + "     " + o);
            Console.WriteLine(" " + o + "    " + "     " + o);
            Console.WriteLine("  " + o + "   " + "    " + o);
            Console.WriteLine("   " + o + "  " + "   " + o);
            Console.WriteLine("    " + o + "  " + " " + o);
            Console.WriteLine("     " + o + " " + o);
            Console.WriteLine("      " + o);
        }
Reply all
Reply to author
Forward
0 new messages