//lab 11b1.cpp
#include <ncurses.h>
void printshape(int row, int col);
int main()
{
int row=5, col=5;
char ch;
initscr();
keypad(stdscr, TRUE);
noecho();
printshape(row,col);
ch = getch();
endwin();
return 0;
}
void printshape(int row, int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw("*");
}
}
void printshape(int row, int col);
int main()
{
int row=5, col=5;
char ch;
initscr();
keypad(stdscr, TRUE);
noecho();
printshape(row,col);
ch = getch();
endwin();
return 0;
}
void printshape(int row, int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw("*");
}
}
#include <ncurses.h>
void printshape(int row, int col);
void eraseshape(int row, int col);
int main()
{
int row=5, col=5;
initscr();
keypad(stdscr, TRUE);
noecho();
printshape(row,col);
getch();
eraseshape(row,col);
getch();
endwin();
return 0;
}
void printshape(int row, int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw("*");
}
}
void eraseshape(int row,int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw(" ");
}
}
void printshape(int row, int col);
void eraseshape(int row, int col);
int main()
{
int row=5, col=5;
initscr();
keypad(stdscr, TRUE);
noecho();
printshape(row,col);
getch();
eraseshape(row,col);
getch();
endwin();
return 0;
}
void printshape(int row, int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw("*");
}
}
void eraseshape(int row,int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw(" ");
}
}
#include <ncurses.h>
void printshape(int row, int col);
void eraseshape(int row, int col);
int main()
{
int row=5, col=5, r, c;
int ch;
initscr();
keypad(stdscr, TRUE);
noecho();
getmaxyx(stdscr,r,c);
printshape(row,col);
ch = getch();
while (ch!='q' && ch!='Q')
{
eraseshape(row,col);
if (ch==KEY_UP)
row=row-1;
else if (ch==KEY_DOWN)
row=row+1;
else if (ch==KEY_LEFT)
col=col-1;
else if (ch==KEY_RIGHT)
col=col+1;
if (row>r-5)
row=row-1;
else if (row<1)
row=row+1;
else if (col>c-5)
col=col-1;
else if (col<1)
col=col+1;
printshape(row,col);
ch=getch();
}
endwin();
return 0;
}
void printshape(int row, int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw("*");
move(1,1);
}
}
void eraseshape(int row,int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw(" ");
move(1,1);
}
}
void printshape(int row, int col);
void eraseshape(int row, int col);
int main()
{
int row=5, col=5, r, c;
int ch;
initscr();
keypad(stdscr, TRUE);
noecho();
getmaxyx(stdscr,r,c);
printshape(row,col);
ch = getch();
while (ch!='q' && ch!='Q')
{
eraseshape(row,col);
if (ch==KEY_UP)
row=row-1;
else if (ch==KEY_DOWN)
row=row+1;
else if (ch==KEY_LEFT)
col=col-1;
else if (ch==KEY_RIGHT)
col=col+1;
if (row>r-5)
row=row-1;
else if (row<1)
row=row+1;
else if (col>c-5)
col=col-1;
else if (col<1)
col=col+1;
printshape(row,col);
ch=getch();
}
endwin();
return 0;
}
void printshape(int row, int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw("*");
move(1,1);
}
}
void eraseshape(int row,int col)
{
for (int i=0; i<5; i++)
for (int j=0; j<i+1; j++)
{
move(row+i,col+j);
printw(" ");
move(1,1);
}
}
0 comments:
Post a Comment