Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n;
- cin << n;
- int verseNumber = 2*n-1;
- int maxPrespaces = n-1;
- int width = n+2*(n-1);
- for(int verse = 0; verse<verseNumber; verse++){
- for(int prespaces = abs(maxPrespaces-verse); prespaces>0; prespaces-- ){
- for(int i = 0; i< prespaces; i++) cout << " ";
- }
- if(verse == 0 || verse == (verseNumber-1)){ //góra i dół
- for(int top = n; top>0; top--){
- cout << "#";
- }
- }
- else{
- cout << "#";
- for(int middleSpaces = n; middleSpaces <= (width-2); middleSpaces++){ //dwa # po bokach zawsze sa
- for(int i = 0; i<middleSpaces; i++) cout << " ";
- }
- for(int middleSpaces = (width-2-1); middleSpaces >= n; middleSpaces++){ //dwa # po bokach zawsze sa
- for(int i = 0; i<middleSpaces; i++) cout << " ";
- }
- cout << "#";
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement