lotrsimp12345 37 Posting Pro in Training

Here is the code I am not sure what you mean.
my_bst_node.h

//create bst node

#ifndef MY_BST_NODE_H
#define MY_BST_NODE_H

#include <iostream>

using namespace std;

template<class KT,class DT>
class my_bst_node
{
public:
	my_bst_node();
	my_bst_node(KT tag, DT info, my_bst_node* l=0, my_bst_node* r=0);

	KT key;
	DT data;
	my_bst_node* left;
	my_bst_node* right;
};

template<class KT, class DT>
my_bst_node<KT,DT>::my_bst_node()
{
		left=right=0;
}

template<class KT, class DT>
my_bst_node<KT,DT>::my_bst_node(KT tag, DT info, my_bst_node* l, my_bst_node* r)
{
		key=tag;
		data=info;
		left=l; 
		right=r;
}

#endif

my_bst.h

//operations that a bst can perform

#ifndef MY_BST_H
#define MY_BST_H
#include <iostream>
#include "my_bst_node.h"

using  namespace std;

template<class KT,class DT>
class my_bst
{
public:
	//default constructor
	my_bst();

	//inserts a new node into binary tree
	void insert(KT searchkey, const DT &newDataItem);

	//search for the key and if found return true
	void search(KT searchkey);

	//prints out tree based on visiting the root node, then the left subtree and last the right subtree
	void preorder_print();

	//prints out tree based on visiting the left subtree, then the root node, and last the right subtree
	void inorder_print();

	//prints out tree based on visiting the left subtree, then the right subtree, and last the root node
	void postorder_print();

	//remove data item
	void remove(KT searchkey);

	//returns height of BST
	int height();

	//check if tree is balanced
	void balanced();

	//output tree structure
	void show(int tree);

private:
	my_bst_node<KT,DT>* root;

	//helper function of insert
	void insert(my_bst_node<KT,DT>*& newnode ,my_bst_node<KT,DT>*& nodepointer);

	//helper function of search
	void search(my_bst_node<KT,DT>*& d, const KT& searchkey);

	//helper function of preorder print
	void preorder_print(my_bst_node<KT,DT>*& f);

	//helper function of …
lotrsimp12345 37 Posting Pro in Training

use getline till end of line using \n and then you can create substrings with delimeters.
maybe use getline() in conjunction with stream operators such as >> since you want to read in integers or numbers.

lotrsimp12345 37 Posting Pro in Training

First of all instead of writing out all those numbers on top i would put it in a loop by using a variable increment that variable and so forth Also to create a book of * use \n and . Make your life a lot easier. Don't have to type as much :). Easy to reuse you code.

Instead of using all those char arrays use string and getline() which should allow you to put in a delimiter to stop at.



setw() sets the field width of the next item only. So I don't think you should be having problems. Maybe you could explain the problem.

#include <iostream>

using namespace std;

int main()
{
	int j;
	for(int i=0; i<=5; i++)
	{
		for(j=0; j<=9; j++)
		{
			cout<<j;
		}
			j=0;
	}

	return 0;
}

Do something like this with the remainder of the *. Make your code look less clutter and easier to read :).

lotrsimp12345 37 Posting Pro in Training

thanks for the help. I figured it out.

Salem commented: Excellent - that's the spirit! +17
lotrsimp12345 37 Posting Pro in Training
Implementation file

using namespace std;
#include "Interface.h"
#include <time.h>



void timer::start()
{
    if(! running)
    {
        begin=(unsigned int) clock();
        running=true;
    }
}

void timer::end()
{
    if(running)
    {
        finish=(unsigned int) clock();
        running=false;
    }
}

int timer::elapsed()
{
    if(running)
    {
        return((unsigned int) clock()-begin);
    }
    else
    {
        return finish-begin;
    }
}

int timer::output(unsigned int seconds)
{
    return seconds >= elapsed();
}




interface file
#ifndef INTERFACE_H_INCLUDED
#define INTERFACE_H_INCLUDED
//#include <time.h>
class timer
{
    public:
    void start();
    void end();
    int elapsed();
    int subtract();
    int add();
    int output(unsigned int seconds);
    private:
    bool running;
    int begin;
    int finish;
};
#endif // INTERFACE_H_INCLUDED


main file

#include <iostream>
using namespace std;
#include "Interface.h"
#include <conio.h>




    int main()
    {
        timer t;
        bool quit = false;
        char choice;
        choice=getch();
        while(! quit)
        {
            t.start();
            t.end();
            cout<<"the time difference is"<<t.elapsed();
        }
        return 0;
    }
jephthah commented: he' +11