asmodeus94

piramidy

Nov 5th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<iostream>    
  2. #include<cstdio>
  3. #include <windows.h>  
  4. using namespace std;
  5. HANDLE g_hConsol = GetStdHandle(STD_OUTPUT_HANDLE);
  6.  
  7. void gotoxy(const int x11, const int y22)
  8. {
  9.         COORD coord = {x11, y22};
  10.         SetConsoleCursorPosition(g_hConsol, coord);
  11. }
  12. int dl=0,zapX;
  13. int main(){        
  14. system("cls");
  15. cout<<"Podaj dlugosc piramidki";cin>>dl;
  16. system("cls");
  17. for(int y=1;y<=dl;y++){
  18.     for(int x=1;x<=y;x++){
  19.     gotoxy(20-x,y-1);cout<<"X";
  20.     gotoxy(20+x,y-1);cout<<"X";
  21.     }
  22.     gotoxy(20,y-1);cout<<"O";
  23. }
  24. for(int y=dl;y>=1;y--){
  25.     for(int x=1;x<=y;x++){
  26.     gotoxy(20+dl*2-x,dl-y);cout<<"X";
  27.     gotoxy(20+dl*2+x,dl-y);cout<<"X";
  28.     }
  29.     gotoxy(20+dl*2,dl-y);cout<<"O";
  30. }
  31. getchar();getchar();    
  32. }
Advertisement
Add Comment
Please, Sign In to add comment