asdasd

Sunday, May 9, 2010

IPE 2010 1st Semester Final Paper 2b Ncurses My Answer


//IPE 2010 1st Semester Final Paper 2(b)
//Naduntw.blogspot.com

#include< ncurses.h >

int main()
{
      initscr();                       //Initialize Screen
      start_color();                //Initialize Colors
      init_pair(1,2,4);             //Define Color Pair 1
      init_pair(2,6,5);             //Define Color Pair 2
      init_pair(3,3,7);             //Define Color Pair 3
      init_pair(4,5,2);             //Define Color Pair 4
      init_pair(5,7,3);             //Define Color Pair 5
      int x=16;              //Declaring and assigning Start Column value  
      int y=11;              //Declaring and assigning Start Row value
      attrset(COLOR_PAIR(1));  //Make current color scheme to Pair 1
      for(;y<17;y++,x--)
      {
            move(y,x);
            printw("*");
            refresh();
            for(int i=0;i<50000000;i++)
            {}
            refresh();
      }
      y--;
      x=x+2;
      attrset(COLOR_PAIR(2));  //Make current color scheme to Pair 2
      for(;x<18;x++)
      {
            move(y,x);

            printw("*");
            refresh();
            for(int i=0;i<50000000;i++)
            {}
            refresh();
      }
      y--;
      x--;
      attrset(COLOR_PAIR(3));  //Make current color scheme to Pair 3
      for(;y>3;y--)
      {
            move(y,x);
            printw("*");
            refresh();
            for(int i=0;i<50000000;i++)
            {}
            refresh();
      }
      y=y+2;
      x++;
      attrset(COLOR_PAIR(4));   //Make current color scheme to Pair 4
      for(;y<11;y++,x++)
      {
             move(y,x);
             printw("*");
             refresh();
             for(int i=0;i<50000000;i++)
             {}
             refresh();
      }
      x--;
      y--;
      attrset(COLOR_PAIR(5));  //Make current color scheme to Pair 5
      for(;x>17;x--)
      {
              move(y,x);
              printw("*");
              refresh();
              for(int i=0;i<50000000;i++)
              {}
              refresh();
      }
      getch();
      endwin();

      return 0;

}

1 comment:

නදුන් said...

This is the easiest way...

 
back to top