 |
|
|
|
 |
Fraggle
trancEaddict Neverland

Registered: Mar 2001
Location: Sydney, AUSTRALIA
|
|
|
Oct-13-2001 04:20
|
|
|
 |
 |
trancaholic
Danish Prophet of Doom

Registered: Oct 2000
Location: Aalborg
|
|
|
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.
|
|
Oct-14-2001 02:42
|
|
|
 |
 |
phasedout
Senior tranceaddict
Registered: Apr 2001
Location: Santa Barbara, CA
|
|
|
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
|
|
Oct-14-2001 23:19
|
|
|
 |
 |
jzmhed1
Supreme tranceaddict

Registered: Feb 2001
Location: SANDOG, CA
|
|
|
| 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;
|
|
Oct-15-2001 05:39
|
|
|
 |
 |
Coup
Retired

Registered: May 2001
Location: England, UK
|
|
|
Oct-15-2001 06:10
|
|
|
 |
All times are GMT. The time now is 17:14.
Forum Rules:
You may not post new threads
You may not post replies
You may not edit your posts
|
HTML code is ON
vB code is ON
[IMG] code is ON
|
|
|
|
|
|
Contact Us - return to tranceaddict
Powered by: Trance Music & vBulletin Forums
Copyright ©2000-2026, Jelsoft Enterprises Ltd.
Privacy Statement / DMCA
|