Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (menu_choice == "D" || menu_choice == "d")
- {
- cout << "You have selected to print a diamond shape of characters.\n";
- cout << "Please enter the character you wish to use: ";
- cin >> character;
- cout << "Please enter the width of the diamond (odd number): ";
- cin >> width;
- if ((width%2)==0 || width < 0)
- {
- cout << "The width should be POSITIVE and ODD. Please re-enter the width: ";
- cin >> width;
- }
- for (int i = 1 ; i <= ((width+1)/2); i++)
- {
- for (int j = width ; j > i ; j--)
- {
- cout << " ";
- }
- for (int k = i ; k >= 1 ; k--)
- {
- cout << character;
- }
- for (int m = 2; m <= i; m++)
- {
- cout << character;
- }
- cout << endl;
- }
- }
Add Comment
Please, Sign In to add comment