Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 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.     int a;
  26.     int b;
  27.     char c;
  28.     int d;
  29.     int e;
  30.     cout<<"Please enter a width: ";
  31.     cin>>a;
  32.     cout<<"Please enter a height: ";
  33.     cin>>b;
  34.     cout<<"Please enter a symbol: ";
  35.     cin>>c;
  36.     cout<<"Please enter an X coordinate: ";
  37.     cin>>d;
  38.     cout<<"Please enter a Y coordinate: ";
  39.     cin>>e;
  40.    
  41.     for(int g=0; g<b; g++)
  42.     {
  43.         gotoxy(d,e+5);
  44.         for(int f=0; f<a; f++)
  45.         {
  46.            
  47.             cout<<c;
  48.         }
  49.         cout<<endl;
  50.         e++;
  51.     }
  52.    
  53.     for(int g=0; g<b-2; g++)
  54.     {
  55.         gotoxy(d+1,e-b+6);
  56.         for(int f=0; f<a-2; f++)
  57.         {
  58.            
  59.             cout<<" ";
  60.         }
  61.         cout<<endl;
  62.         e++;
  63.     }
  64.       getch();
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement