Informatică, întrebare adresată de catalinacoptu9, 8 ani în urmă

ajutor urgent in 3 minute
punctul c)​

Anexe:

Răspunsuri la întrebare

Răspuns de grigore2018
1

Răspuns:

#include <iostream>

using namespace std;

int main() {

   int n = 5;

   for (int i = 0; i < n; i++) {

       for (int j = 0; j < i; j++) {

           cout << " ";

       }

       for (int k = 0; k < (2 * n - 1) - (2 * i); k++) {

           cout << "1";

       }

       cout << endl;

   }

   for (int i = 0; i < n-1; i++) {

       for (int j = 0; j < n-2-i; j++) {

           cout << " ";

       }

       for (int k = 0; k < (2 * i) + 3; k++) {

           cout << "1";

       }

       cout << endl;

   }

   return 0;

}


Piramida
111111111

1111111

 11111

  111

   1

  111

 11111

1111111

111111111

#include <iostream>

using namespace std;

int main() {

   for (int i = 7; i >= 1; i--) {

       for (int j = 1; j <= 7 - i; j++) {

           cout << " ";

       }

       for (int j = 1; j <= (2 * i) - 1; j++) {

           cout << "*";

       }

       cout << endl;

   }

   return 0;

}


Rezultat
*************

***********

 *********

  *******

   *****

    ***

     *

Alte întrebări interesante