Skip to content

Instantly share code, notes, and snippets.

@draganczukp
Created June 2, 2017 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draganczukp/e52112728ff9dec482f35ccff8ce08ab to your computer and use it in GitHub Desktop.
Save draganczukp/e52112728ff9dec482f35ccff8ce08ab to your computer and use it in GitHub Desktop.
Trójkąt z gwiazdek
#include <iostream>
using namespace std;
int main()
{
int wys = 0;
cout << "Podaj wysokość: ";
cin >> wys;
//Z góry na dół;
for (int y = 1; y <= wys; y++) {
int odstep = wys - y;
//Odstęp od krawędzi ekranu
for (int x = 1; x <= odstep;x++) {
cout << " ";
}
int gwiazdki = (y * 2) - 1;
for (int x = 1; x <= gwiazdki; x++) {
cout << "*";
}
cout << endl;
}
//Dodaj tą linię tylko jak nie wyświetla się "naciśnij dowolny klawisz..."
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment