Write a program trapezoid.cpp that prints an upside-down trapezoid of given width and height. However, if the input height is impossibly large for the given width, then the program should report,

Respuesta :

Answer:

#include <iostream>

using namespace std;

int main()

{    

   int rows, width, height, spaces, stars; // declare values

   cout << "enter width" << endl;

   cin >> width;

   cout << "enter height" << endl;

   cin >> height;

   for (int row = 0; row < height; ++row) {

       for (int col = height + row; col > 0; --col) {

           if (height % 6 == 1) {  

               cout << "Impossible shape!" << endl;

               return 0;

           }

           cout << " ";

       }

       for (int col = 0; col < (width - 2 * row); ++col) {

           cout << "*";

           spaces += 1;

           stars -= 2;

       }

       cout << endl;