Created
June 2, 2017 08:48
-
-
Save draganczukp/e52112728ff9dec482f35ccff8ce08ab to your computer and use it in GitHub Desktop.
Trójkąt z gwiazdek
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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