Page 16 of 20
Re: C++/C programming discussion
Posted: Mon Oct 04, 2010 6:40 pm
by Matthew
I'd only be willing to help if you swapped vectors for arrays. Learning how to use dynamic arrays will be useful to you, so I recommend it. It's a skill you'll need eventually if you are serious about programming.
Re: C++/C programming discussion
Posted: Mon Oct 04, 2010 6:52 pm
by Scott
Matthew wrote:I'd only be willing to help if you swapped vectors for arrays. Learning how to use dynamic arrays will be useful to you, so I recommend it. It's a skill you'll need eventually if you are serious about programming.
Wikipedia wrote:C++'s std::vector is an implementation of dynamic arrays
Re: C++/C programming discussion
Posted: Mon Oct 04, 2010 7:20 pm
by Matthew
It's not your own dynamic array. I don't want to look into vectors again right now. I can think about dynamic arrays you make yourself. I'd be the best help if you used malloc.
Re: C++/C programming discussion
Posted: Mon Oct 04, 2010 8:04 pm
by Scott
Matthew wrote:It's not your own dynamic array. I don't want to look into vectors again right now. I can think about dynamic arrays you make yourself. I'd be the best help if you used malloc.
I'll look into the allocating methods and see what I can come up with.
EDIT:
Didn't mean to kill the conversation. I am quite busy right now so I won't get around trying the new parameter for a while, but I will post it when I do.
Re: C++/C programming discussion
Posted: Tue Oct 05, 2010 7:54 pm
by Matthew
Thats fine. I'll likely be busy getting my iphone application ready. I just got my iphone.
Re: C++/C programming discussion
Posted: Tue Oct 05, 2010 9:37 pm
by Scott
Matthew wrote:I just got my iphone.
Unlocked?
Re: C++/C programming discussion
Posted: Wed Oct 06, 2010 4:48 am
by Matthew
Well, it uses a SIM so I guess so? I'm typing this on it on a bus right now

Hopefully the university has wifi.
Re: C++/C programming discussion
Posted: Wed Oct 06, 2010 3:05 pm
by Scott
I got my textbook back finally and will do some reading this weekend (attempting to read 600+ pages to finish) and should be much more versed in C++

Re: C++/C programming discussion
Posted: Wed Oct 06, 2010 5:54 pm
by Matthew
I learn things by reading the specific parts I want to know and then trying it out myself. I never follow any particular pattern either. I never read from one side of a book to the other.
Re: C++/C programming discussion
Posted: Wed Oct 06, 2010 8:30 pm
by Scott
Matthew wrote:I learn things by reading the specific parts I want to know and then trying it out myself. I never follow any particular pattern either. I never read from one side of a book to the other.
Somethings are hard to know if they exist if you never learn about them though. For instance, I would never think of the need for virtual methods because it is has a fairly specific, yet useful purpose, and describing that need would be difficult, so finding it would also be a struggle. I read as much as I can in case I ever need it.
Re: C++/C programming discussion
Posted: Thu Oct 07, 2010 7:11 pm
by Matthew
I learn everything I consider important in the order I wish to learn it. I can always do research on particular features later.
Re: C++/C programming discussion
Posted: Thu Oct 07, 2010 7:22 pm
by Scott
Matthew wrote:I learn everything I consider important in the order I wish to learn it. I can always do research on particular features later.
Scott wrote:Somethings are hard to know if they exist if you never learn about them though. For instance, I would never think of the need for virtual methods because it is has a fairly specific, yet useful purpose, and describing that need would be difficult, so finding it would also be a struggle. I read as much as I can in case I ever need it.
EDIT:
Quicksort is really getting to me...Hopefully I can come up with something so I can at least get some guidance because as of now, I'm completely distraught...
Re: C++/C programming discussion
Posted: Sat Oct 09, 2010 5:30 pm
by Matthew
You might like this simple approximate normally distributed random number generator:
Code: Select all
double normal_distribution_rand(double mu, double sigma) {
float i = 0;
for (int x = 0; x < 32; x++) {
i += ((float) rand()/ RAND_MAX) - 0.5;
}
i /= 32;
i *= (sigma/0.05);
i += mu;
return i;
}
Re: C++/C programming discussion
Posted: Sat Oct 09, 2010 6:01 pm
by Scott
The random pivot is not what's getting to me. It's checking the size of an array.
Re: C++/C programming discussion
Posted: Sat Oct 09, 2010 6:07 pm
by Matthew
That algorithm is unrelated. It creates random numbers which are normally distributed with a certain mean and standard deviation. I just made it today. It uses the central limit theory, a theory my maths teacher said was practically useless.
Checking the size of an array? You should store the array in a structure with an integer keeping the size.