khaty79
06-15-03, 11:22 PM
hello... frenzz, i dont know how to convert from visual C++ to vb.net... it is possible to do it??? cna all of u help me.. urgent!!
#include <iostream>
using namespace std;
class ADTstack
{
private:
int stack[5];
int topstack;
int num;
public:
ADTstack ()
{topstack = -1;}
int empty ()
{
if (topstack == -1)
return 1;
else
return 0;
}
int full ()
{
if (topstack == 5)
return 1;
else
return 0;
}
void push (int num)
{
if (!full ())
{
topstack++;
cout << " \n inserting " << num ;
stack[topstack] = num;
}
else
cout<<"Stack is full"<<endl;
}
int pop ()
{
int num;
if (!empty ())
{
num = stack[topstack];
topstack--;
return num;
}
else
{
cout<<"Stack is empty"<<endl;
return 0;
}
}
};
class ADTstackB
{
private:
int stack[5];
int topstack;
int num;
public:
ADTstackB ()
{topstack = -1;}
int empty ()
{
if (topstack == -1)
return 1;
else
return 0;
}
int full ()
{
if (topstack == 5)
return 1;
else
return 0;
}
void push (int num)
{
if (!full ())
{
topstack++;
stack[topstack] = num;
}
else
cout<<"Stack is full"<<endl;
}
int pop ()
{
int num;
if (!empty ())
{
num = stack[topstack];
topstack--;
return num;
}
else
{
cout<<"Stack is empty"<<endl;
return 0;
}
}
};
class LinkList
{
public:
int list[5];
int pre;
int post;
public:
LinkList ()
{
pre = 0;
post = 0;
}
void addElement (int pre11 , int post11 , int value11)
{
if ( pre == post )
{
list[pre]=value11 ;
cout << " \n inserting to link list at index " << pre << " value == " << list[pre] ;
}
else
{
list[post11] = value11 ;
cout << " \n inserting to link list at index "<< post << " value == " << list[post11];
}
post++ ;
}
void pretraverse ()
{
for ( int i = pre ; i < 5 ; i++ )
{
int retval = list[i];
cout << " \n index == " << i << " value == " << retval ;
}
}
};
void main ()
{
int c;
const int True = 1, False = 2;
ADTstack s;
ADTstackB t;
LinkList mylist ;
int op = 0;
//int sameOP = True; // assume string with same action
cout << " \n Creating stack " ;
for(op=0; op<5; op++)
s.push(op);
//now pop stack,comparing pre and post action of each operator.
// and create a link list
cout << " Stack has created ";
cout << " \n inserting to link list " ;
while(!s.empty())
{
c = s.pop(); //get next operator from stack
//then, insert the node of linked list
cout << " \n processing " << c ;
mylist.addElement(mylist.pre , mylist.post , c ) ;
}
cout << " \n Link list has created successfully " ;
cout << " \n Here is the output from Link List using pre pointer " ;
mylist.pretraverse() ;
cout << " \n finished " ;
}
#include <iostream>
using namespace std;
class ADTstack
{
private:
int stack[5];
int topstack;
int num;
public:
ADTstack ()
{topstack = -1;}
int empty ()
{
if (topstack == -1)
return 1;
else
return 0;
}
int full ()
{
if (topstack == 5)
return 1;
else
return 0;
}
void push (int num)
{
if (!full ())
{
topstack++;
cout << " \n inserting " << num ;
stack[topstack] = num;
}
else
cout<<"Stack is full"<<endl;
}
int pop ()
{
int num;
if (!empty ())
{
num = stack[topstack];
topstack--;
return num;
}
else
{
cout<<"Stack is empty"<<endl;
return 0;
}
}
};
class ADTstackB
{
private:
int stack[5];
int topstack;
int num;
public:
ADTstackB ()
{topstack = -1;}
int empty ()
{
if (topstack == -1)
return 1;
else
return 0;
}
int full ()
{
if (topstack == 5)
return 1;
else
return 0;
}
void push (int num)
{
if (!full ())
{
topstack++;
stack[topstack] = num;
}
else
cout<<"Stack is full"<<endl;
}
int pop ()
{
int num;
if (!empty ())
{
num = stack[topstack];
topstack--;
return num;
}
else
{
cout<<"Stack is empty"<<endl;
return 0;
}
}
};
class LinkList
{
public:
int list[5];
int pre;
int post;
public:
LinkList ()
{
pre = 0;
post = 0;
}
void addElement (int pre11 , int post11 , int value11)
{
if ( pre == post )
{
list[pre]=value11 ;
cout << " \n inserting to link list at index " << pre << " value == " << list[pre] ;
}
else
{
list[post11] = value11 ;
cout << " \n inserting to link list at index "<< post << " value == " << list[post11];
}
post++ ;
}
void pretraverse ()
{
for ( int i = pre ; i < 5 ; i++ )
{
int retval = list[i];
cout << " \n index == " << i << " value == " << retval ;
}
}
};
void main ()
{
int c;
const int True = 1, False = 2;
ADTstack s;
ADTstackB t;
LinkList mylist ;
int op = 0;
//int sameOP = True; // assume string with same action
cout << " \n Creating stack " ;
for(op=0; op<5; op++)
s.push(op);
//now pop stack,comparing pre and post action of each operator.
// and create a link list
cout << " Stack has created ";
cout << " \n inserting to link list " ;
while(!s.empty())
{
c = s.pop(); //get next operator from stack
//then, insert the node of linked list
cout << " \n processing " << c ;
mylist.addElement(mylist.pre , mylist.post , c ) ;
}
cout << " \n Link list has created successfully " ;
cout << " \n Here is the output from Link List using pre pointer " ;
mylist.pretraverse() ;
cout << " \n finished " ;
}