(Displaying Shapes with Asterisks) Write a program that prints a box, an oval, an arrow and a diamond as follows:
Solution:
#include <iostream> using std::cin; using std::cout; using std::endl; int main() { cout << "*********\n" << "* *\n" << "* *\n" << "* *\n" << "* *\n" << "* *\n" << "* *\n" << "* *\n" << "*********\n"; cout << " *** \n" << " * * \n" << "* *\n" << "* *\n" << "* *\n" << "* *\n" << "* *\n" << " * * \n" << " *** \n"; cout << " * \n" << " *** \n" << " ***** \n" << " * \n" << " * \n" << " * \n" << " * \n" << " * \n" << " * \n"; cout << " * \n" << " * * \n" << " * * \n" << " * * \n" << "* * \n" << " * * \n" << " * * \n" << " * * \n" << " * \n"; return 0; }
Per book instructions: The shapes should be displayed horizontally.
ReplyDelete