Created
December 19, 2023 16:12
-
-
Save bistcuite/8dbd47e3455a5026dbccc0e0ebc7f7c9 to your computer and use it in GitHub Desktop.
unfinished star pattern project
This file contains hidden or 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> | |
#include <conio.h> | |
#include <windows.h> | |
#include <cstdlib> | |
using namespace std; | |
// going to (x,y) in terminal windows | |
void gotoxy(short int x, short int y) | |
{ | |
COORD pos = { x, y }; | |
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); | |
} | |
// find x-position of cursor | |
int wherex() | |
{ | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); | |
return csbi.dwCursorPosition.X; | |
} | |
// find y-position of cursor | |
int wherey() | |
{ | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); | |
return csbi.dwCursorPosition.Y; | |
} | |
int main() | |
{ | |
// getting size of terminal windows and store it in rows and columns variables. | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
int columns, rows; | |
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); | |
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; | |
rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; | |
int x, y; | |
int i,j = 1; | |
system("cls"); | |
for(int i = 1;i<=columns;i++) | |
{ | |
gotoxy(i,0); | |
cout<<"*"; | |
Sleep(100); | |
gotoxy(i,5); | |
cout<<"*"; | |
Sleep(100); | |
gotoxy(i,10); | |
cout<<"*"; | |
Sleep(100); | |
gotoxy(columns-i,4); | |
cout<<"*"; | |
Sleep(100); | |
gotoxy(columns-1i,9); | |
cout<<"*"; | |
Sleep(100); | |
gotoxy(columns-i,14); | |
cout<<"*"; | |
Sleep(100); | |
} | |
getch(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment