Banner Ad

    A    L    W    A    Y    S           D    E    S    I    R    E           T    O           L    E    A    R    N           S    O    M    E    T    H    I    N    G           U    S    E    F    U    L   

Monday, May 9, 2011

2010 Final IPE_UNIXC_-1151b question 1

#include <ncurses.h>
void rooftriangle(int srow,int scol,int height);
void rectangle(int srow,int scol,int height,int width);
int main()
{

      initscr();
      start_color();
      init_pair(1,0,1);
      init_pair(2,1,3);
      init_pair(3,4,7);
     


      attrset(COLOR_PAIR(1));
      rooftriangle(6,15,5);
      rooftriangle(17,15,5);
     
      attrset(COLOR_PAIR(3));
      rectangle(2,21,7,19);



      attrset(COLOR_PAIR(2));
      rectangle(9,23,5,5);







      getch();
      endwin();

      return 0;
}
void rooftriangle(int srow,int scol,int height)
{     int c=0;
      for(int y=scol;y<=scol+height;y++)
      {    
            for(int x=srow;x<=srow+c;x++)
            {
            move(y,x);
            printw("*");
            }
            for(int x=srow;x>=srow-c;x--)
                {
                move(y,x);
                printw("*");
                }
            c++;
      }    

}
void rectangle(int srow,int scol,int height,int width)
{
       for(int y=scol;y<=scol+height;y++)
        {
                for(int x=srow;x<=srow+width;x++)
                {
                move(y,x);
                printw("*");
                }

      }

}

0 comments:

Related Posts Plugin for WordPress, Blogger...

your comments