Forum: C++ Aug 7th, 2009 |
| Replies: 1 Views: 367 How do you erase an element thats inside a map. Not the key but the element the key is pointing to? This doesnt seem to be doing what i want it to.
map<int, vector<int> > my_map;
map<int,... |
Forum: C++ Aug 6th, 2009 |
| Replies: 7 Views: 571 Thanks for the reply ancientdragon, that seems like something I can work with. Should I not be using vectors for this? |
Forum: C++ Aug 6th, 2009 |
| Replies: 7 Views: 571 Ok so here is some more code, it has the idea of what i want to do with my program.
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class Set |
Forum: C++ Aug 6th, 2009 |
| Replies: 7 Views: 571 I was wondering if you guys might help me figure out how to make a vector of vectors like so,
The user will name the set say 'A'. And then using 'A' as a key you can then find the set name and... |
Forum: C++ Aug 6th, 2009 |
| Replies: 4 Views: 330 I have a vector which i wish to fill with char's, so that each char is then a pointer to a vector.
vector<char> list;
list[0] = 'A';
list[1] = 'B';
How do I make 'A' and 'B' pointers to... |
Forum: C++ Jun 13th, 2009 |
| Replies: 5 Views: 295 Yeah thats what im trying to do, get it to go through all the levels of the tree until it finds the first null child. I thought like a preorder traversal implementation would do the trick...but its... |
Forum: C++ Jun 13th, 2009 |
| Replies: 5 Views: 295 Yeah this works...I meant I want it to stop after it finds the first null child. I cant figure out how to do it. |
Forum: C++ Jun 13th, 2009 |
| Replies: 5 Views: 295 I want to find the first null child in a tree and return that node of the tree.
Im thinking something like this but it doesnt seem to work the way I want.
node *Find_Empty_Node(node* root)
{... |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 501 I want the minimal pointer because it is the left most node for my tree. If i have it how do I get it in a variable like this-
root->children[0] = get_lowest(root) ? |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 501 Yeah the node type def is this
struct node
{
vector <node*> childrent;
int item;
}; |
Forum: C++ Jun 11th, 2009 |
| Replies: 6 Views: 501 IF i have this function...
node* get_lowest(node* root)
{
node* min = root->child[0];
for(int i = 0; i<root->child.size();i++)
{
if(min > root->child[i]) |
Forum: C++ Jun 9th, 2009 |
| Replies: 8 Views: 326 Here is the whole thing...
class Tree
{
public:
Tree() { root = NULL; }
bool isEmpty() const { return root==NULL; }
void insert(int, int); |
Forum: C++ Jun 9th, 2009 |
| Replies: 8 Views: 326 Something like this?
void Tree::insert(int num, int num2)
{
node* insert = new node;
insert->item = num;
if(isEmpty())
{ |
Forum: C++ Jun 9th, 2009 |
| Replies: 8 Views: 326 Ah yeah that was just a blind man that didnt notice that. But now, how would I check for an open node?
void Tree::insert(int num, int num2)
{
if(isEmpty())
{
root = new node;... |
Forum: C++ Jun 9th, 2009 |
| Replies: 8 Views: 326 Would someone be so kind as to help me with this insert. The function insert takes two numbers, num and num2. num is the number to insert in the tree and num2 is the number of children to the... |
Forum: C++ Jun 5th, 2009 |
| Replies: 5 Views: 359 So If i had this how would I keep track of the root children?
#include<iostream>
#include<vector>
using namespace std;
class Tree
{ |
Forum: C++ Jun 5th, 2009 |
| Replies: 5 Views: 359 So in a binary tree the insertion looks something like this:
void btree::insert(int num)
{
if(root!=NULL)
{
insert(num, root);
}
else |
Forum: C++ Dec 2nd, 2008 |
| Replies: 6 Views: 670 Well that sort of works but if the char I want to delete/erase is at the end of the string my compiler crashes. I dont understand how to delete/erase a char that is not an alphanumeric type.
... |
Forum: C++ Dec 2nd, 2008 |
| Replies: 6 Views: 670 How would I delete one char from a string?
string aWord = "question?";
while(aWord[i])
{
if(isalpha(aWord[i]))printf ("character %c is alphabetic\n",aWord[i]);
else
delete[i]aWord;
... |
Forum: C++ Nov 26th, 2008 |
| Replies: 3 Views: 374 If I had a text file with words like this:
word* (start) enable! get&& Words
it would just find the A_Z characters...like this:
word start enable get Words |
Forum: C++ Nov 26th, 2008 |
| Replies: 3 Views: 374 Does anyone know how to search a text file for just alphanumeric words using regex? And could you show me? |
Forum: C++ Nov 25th, 2008 |
| Replies: 6 Views: 771 yes this does run, and setting frequency to zero and determining if a word is already in the tree then incrementing it, is what I need help on. |
Forum: C++ Nov 25th, 2008 |
| Replies: 6 Views: 771 Im trying to count the frequency of words from a file and cant seem to get it to work. My frequency function recognizes the word is there but doesnt return a count for each word yet. The text file... |
Forum: C++ Nov 2nd, 2008 |
| Replies: 3 Views: 483 Im having trouble turning this function into a recursion function, partly because I did it another way and now I cant think of how to do it recursively. Can you help?
int list::recursion(int... |
Forum: C++ Oct 26th, 2008 |
| Replies: 6 Views: 478 Maybe if you run this you will get it better. I need to fill in each "box" with the three numbers. But I need to get to each box with recursion. So if I have an 8 by 8, i need to look in the... |
Forum: C++ Oct 26th, 2008 |
| Replies: 6 Views: 478 Im having trouble seeing this recursion function through. Say I have an 8 by 8 array how would I get the search function to "see" into the middle of the 8 by 8 array. Positions (4,4),... |
Forum: C++ Oct 12th, 2008 |
| Replies: 3 Views: 403 is there a way to not put in integer 3? And just get number.one and number.two into the next function? |
Forum: C++ Oct 12th, 2008 |
| Replies: 3 Views: 403 Say you have a class called example:
class example
{
int one;
int two;
};
and you use this to get numbers from the user: |
Forum: C++ Oct 10th, 2008 |
| Replies: 8 Views: 513 I dont want to cout the char I want pointer[a][b] to be the char. |
Forum: C++ Oct 10th, 2008 |
| Replies: 8 Views: 513 When I insert a char like '*' I get a number in the output. |
Forum: C++ Oct 10th, 2008 |
| Replies: 8 Views: 513 How do I insert a character into a number array? Is it possible? a and b are constants.
for(int i = 0; i <n; i++)
{
pointer[i] = new int[n];
}
for(int i=0;i<n;i++)
{... |
Forum: C++ Oct 9th, 2008 |
| Replies: 4 Views: 525 can you do something like this but with a 2-dim array?
int main()
{
int size;
int *pointer;
cout<<"Enter size\n";
cin>>size;
pointer=new int[size]; |
Forum: C++ Oct 9th, 2008 |
| Replies: 4 Views: 525 Is it possible to ask the user to input the size of a 2-dim array? |
Forum: C++ Oct 8th, 2008 |
| Replies: 5 Views: 487 neither of your answers worked |
Forum: C++ Oct 8th, 2008 |
| Replies: 5 Views: 487 So if I have a header file like this:
template<typename T>
class snake
{
public:
void example();
private:
T *start_Ptr; |
Forum: C++ Oct 5th, 2008 |
| Replies: 8 Views: 658 Ok thanks for the help, I thought I had to delete from the list already created...I didnt think to just not include them! |
Forum: C++ Oct 5th, 2008 |
| Replies: 8 Views: 658 But I want the delete function to delete any duplicates in the linked list. If I just delete that function then I still have the whole Linked list, duplicates included.
the text file contains... |
Forum: C++ Oct 5th, 2008 |
| Replies: 8 Views: 658 #include <iostream>
#include <fstream>
using namespace std;
class List
{
public:
void Insert(int);
void Print(); |
Forum: C++ Oct 5th, 2008 |
| Replies: 8 Views: 658 This just seems to do the samething, I get an empty list by the end. |
Forum: C++ Oct 5th, 2008 |
| Replies: 8 Views: 658 Im having real trouble seeing this, how do I delete something out of a linked list if it is already there? My current delete function just deletes everything out of the list.
the text file... |