Monday, 26 November 2012

Another example of Hanoi Towers.

Find another example of Hanoi Towers on C++

  -> This C++ program is to solve the towers of hanoi problem.
  -> Implemented using recursion.
  -> Works in Microsoft VC++ 6.0 , windows xp.
  -> Header files used 1)iostream.h
void move(int n,char *s,char *i,char *d)
// s stands for source tower
// d stands for destination tower
// i stands for intermediate tower
  // move n-1 disks from source to intermediate tower
  cout<<”disk “<<n<<” is moved from “<<s<<” to “<<d<<endl;
  // move the disk from to source to destination
  // move n-1 disks from intermediate to destination
void main()
 cout<<”This C++ program is to solve the towers of hanoi problem”;
 cout<<”Enter the no. of disks “;
 int n;
 move(n,”source tower”,”intermediate tower”,”destination tower”);

sourse blog -

Sunday, 30 September 2012

Dynamic allocation (example for myself)

// dynamic allocation and polymorphism
#include <iostream>
using namespace std;

class CPolygon {
    int width, height;
    void set_values (int a, int b)
      { width=a; height=b; }
    virtual int area (void) =0;
    void printarea (void)
      { cout << this->area() << endl; }

class CRectangle: public CPolygon {
    int area (void)
      { return (width * height); }

class CTriangle: public CPolygon {
    int area (void)
      { return (width * height / 2); }

int main () {
  CPolygon * ppoly1 = new CRectangle;
  CPolygon * ppoly2 = new CTriangle;
  ppoly1->set_values (4,5);
  ppoly2->set_values (4,5);
  delete ppoly1;
  delete ppoly2;
  return 0;
Example from website: 

Friday, 14 September 2012

Git book languages.

I was surpriced that Pro-git Book has translations into different languages. Well it helps a lot for a students whose first language is not English.
Here is link for Russian Pro-Git Book.
You will find other languages in the left side, just click on link and you will get GitBook in language you need.

Sunday, 9 September 2012

OOP344 again...

Yep, I failed OOP344 last semester. More attention this time.

Wednesday, 14 March 2012

My functions...

For the first part of our team assignment I did this three functions...


void CDialog::draw(int fn = C_FULL_FRAME){
    if(fn == C_FULL_FRAME){                //If fn is C_FULL_FRAME
        CFrame::draw();                    //it will call its parent draw. Then It will draw all the Fields in the Dialog.
    }                                      // it will call its parent draw. Then It will draw all the Fields in the Dialog.
    if(fn != C_FULL_FRAME){                // If fn is not C_FULL_FRAME
        for (int i = 0; i < _fnum; i++){
        _fld[i]->draw;                     // then it will just draw all the Fields in the Dialog.
    if(fn > 0){                            // If fn is a non-zero positive value
        _fld[(fn-1)%_fnum]->draw();   // then it will only draw Field number fn in the dialog.


  CLabel::CLabel(const CLabel& L):CField(L){
                _data = new char[strlen((char*)L._data+1)];
                _data = (char*)0;


void CLabel::set(const void* str){
      if(width() > 0){        //if width() is greater than zero
        strncpy((char*)_data, (char*)str, width());
        ((char*)_data)[width()] = 0;
      if(width() == 0){
        delete [] _data;
        _data = new char[len+1];
        strcpy((char*)_data, (char*)str);


Probably they have several few mistakes which were changed in final team project.


Well, I forgot about this blog... So let's start it over..

Sunday, 15 January 2012

First Post

First Post
TEST test TeSt

Some programming staff would be here later...