Advertisement
RyoMaeda

Drawbox w/cords

Nov 13th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. // base code file
  2.  
  3. #include <iostream>
  4. #include <windows.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <conio.h>
  8. #include <sstream>
  9. #include <fstream>
  10. using namespace std;
  11. void gotoxy(short x, short y) {
  12.     COORD pos = {x, y};
  13.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
  14.     }
  15. // generates a random number between 0 and r inclusive
  16. int random(int r)
  17. {
  18.     return rand()% r + 1;
  19. }  
  20. ///////////////////////////////////////////////////////////////////////
  21. main()
  22. {
  23.       srand(time(NULL));
  24.   // write code here
  25. cout<<"Please enter a symbol:";
  26. char sym;
  27. cin>>sym;
  28. cout<<"Please enter the width:";
  29. int wid;
  30. cin>>wid;
  31. cout<<"Please enter the height:";
  32. int height;
  33. cin>>height;
  34. cout<<"Please enter a x-coordinate:";
  35. int cord;
  36. cin>>cord;
  37. cout<<"Please enter a y-coordinate:";
  38. int cord2;
  39. cin>>cord2;
  40. gotoxy(cord,cord2-2);
  41. for(int counter=0;counter<height;counter++){
  42.         cout<<endl;
  43.         gotoxy(cord,cord2+3-counter);
  44.         cout<<sym;
  45.         for(int counter=0;counter<wid-1;counter++){
  46.             cout<<sym;
  47.         }
  48.     }
  49.  
  50. // leave the following line in all programs
  51.       getch();
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement