|
Calling all C++ nerds :)
|
View this Thread in Original format
| Eugene |
| I refuse to help you because you just called me a "nerd" :stongue: :mad: |
|
|
| Fraggle |
hmm...well i flunked c++!!!
heheehhe :p:p:p
anyway...prolly some &^%$%# recursive solution will do it very simply :(:(:(
|
|
|
| SmackdowN |
"I'll be back" |
|
|
| hypronix |
dude, I think I can help U with part A, I mean it is pretty easy. but I don't understand everything the lab asks for, I can write a program that does the (to make the two means)
the thing is that I have an example version of C++ (Borland C++ Lite) so U wouldn't be able to use the .exe file.
plus, a lil C++ practice wouldn't kill... tell me if U want me to start working on it (but I can start it on Monday only) |
|
|
| Tranzmit |
I know everything about pc's (I'm a technician) but nothing about programming, sorry. I never could be bothered with it as it wasn't my interest, i was always fascinated by CPU archtecture and chipset design and 3D API's and GPU's instead LOL!!!
Sorry about that! |
|
|
| trancaholic |
Please don't take this the wrong way, but...
The problem seem rather trivial. If you have a working compiler environment I can't see how you can fail at this. If, however, you have no knowledge of how to do simple arithmetics such as sqrt(int), and you're already giving up at this challenge, then you're probably in the wrong class, and further pursuit of this career will result in frustration and inferiority-problems.
You're entitled to deem me a stupid prejudist, but judging from the difficulty level of this problem, I guess you're at your first year of programming experience and if you think this is an overwhelming problem there's other aspects of computer science that might appeal more to you.
Though, if you have other reasons for solving this problem, than passing some programming-course, I'll be more than happy to help you out, but if this is your motive, you really ought to solve it yourself. |
|
|
| phasedout |
for the first part of inputing the numbers into an array, i would use a do while
do {
blahblahblah
}while(x!=999);
but of course there are a whole set of different ways to go about that first part |
|
|
| jzmhed1 |
| quote: | Originally posted by trancaholic
Please don't take this the wrong way, but...
The problem seem rather trivial. If you have a working compiler environment I can't see how you can fail at this. If, however, you have no knowledge of how to do simple arithmetics such as sqrt(int), and you're already giving up at this challenge, then you're probably in the wrong class, and further pursuit of this career will result in frustration and inferiority-problems.
You're entitled to deem me a stupid prejudist, but judging from the difficulty level of this problem, I guess you're at your first year of programming experience and if you think this is an overwhelming problem there's other aspects of computer science that might appeal more to you.
Though, if you have other reasons for solving this problem, than passing some programming-course, I'll be more than happy to help you out, but if this is your motive, you really ought to solve it yourself. |
dont listen to this guy, djpsi. i bombed c++ the first time i took it with a D. then i took it at a community college and got an A+. the moral of the story: It's all about how good the teacher is.
anyway, here you go. learn from it, godammit.
#include
#include
#include
int main()
{
int n = 0;
double x;
double h = 0;
double hsum = 0;
double gmean;
double hmean;
double sum = 0;
while(x!=999){
// if ( x==999)
// break;
cout << "Enter a number ( 999 to end )\n";
cin >> x;
sum+= x;
h = 1.0 / x;
hsum+= h;
if( x != 999)
n++;
}
gmean = pow( sum - 999, 1.0/n );
hmean = n / hsum;
cout << "The geometric mean is " << setprecision(2)
<< setiosflags( ios::fixed | ios::showpoint ) << gmean << endl;
cout << "The harmonic mean is " << setprecision(2)
<< setiosflags( ios::fixed | ios::showpoint ) << hmean << endl; |
|
|
| trancaholic |
| quote: | Originally posted by jzmhed1
dont listen to this guy, djpsi. i bombed c++ the first time i took it with a D. then i took it at a community college and got an A+. the moral of the story: It's all about how good the teacher is.
anyway, here you go. learn from it, godammit.
Source here...
|
IMO the gain from being handed full solutions is no match for putting things together for yourself from small examples in your textbook/teaching material. It's like peeing your pants when it's freezing: It will provide you with warmth for a while, but suddenly it will make you more cold than before. Again IMO. |
|
|
| Cru5ad3r |
| quote: | | It's like peeing your pants when it's freezing: It will provide you with warmth for a while, but suddenly it will make you more cold than before. Again IMO. |
HAhah! Nice1 :)
Crusader |
|
|
|
|