Posted by Colin Asquith on 1999-03-19
Ok- here is the grep.
I'm at Uni. and I have a project to do, but this isn't a request for you to
do my homework. I'm looking to learn, not to copy. My C++ is rubbish, but I
want to do this over the weekend for Monday night. Please try and sort me
out!
I'll skim over the details here for what I need to do, if you think you can
help me or point me in the right direction by all means mail me:
ceecsa@xxx.xx.xx.xx
Ok- I have a table of attributes, and each row has boolean attributes and a
kind, like this (for a beer example):
is_it_pale | is_it_creamy | has_a_head | tastes_strong |
kind_of_beer
=========================================================
T | F | T |
F | lager
F | T | T |
T | stout
T | T | N |
N | bitter
..
and so on.
Basically I have a function that calculates the entropy (the best ordering
attribute for a good spread in the table) and then I need to make a decision
tree based on the node I have chosen with the function.
>From this I recurse and use the function to work out which attribute to sort
by and then create this tree. The problem is I'm rubbish at C++ as I have
said. My questions:
* I have an array of structs for the table, is this the best choice?
* How do I use a binary tree here? I have a struct for a node, but I'm
getting confused.
* How can I accept a return as an input? Like if you are asked for a
filename but I have a default file that is used if you press <enter>? As I
can't get cin to do this? Do I need getln or scanf?
* If I have a char that is like this: char name[4]; how can I avoid
type incompatibility with chars that are smaller than this? i.e. I had this
in my code where the filename is. If you press enter then:
char file_name[5];
if(whatever you do for return)
{
file_name = "Jim";
}
else
{
cout << "Please enter...."
blahh!
I get cannot convert char[3] to char[5].
OK-
I think I'll stop there and see how I get on. If anyone does make any sense
of this, and sends me a clue to any of it, then I thank you very kindly
indeed!!
Colin.
Previous post | Next post | Timeline | Home