QA.TechInterviews.com - your tech questions answered
Help C++ Experts Can U Make Me A Prog That Inputs 10 Int Numbers Then Displays The Highest And Lowes
computes the ave of the lowest and highest numbers
Off the top of my head

include <iostream.h>
main{
int[10] n;

cout << "enter ten numbers" << endl;
for (int i = 0; i < 10; i+=2)
{
cin >> n[i]
}

int biggest = 99999, littlest = -999999;

for (int j = 0; j < 10; j++)
{
if n[j] < littlest
littlest = n[j]
else if n[j] < biggest
biggest = n[j]
}

int avg = biggest + littlest /2;
cout << avg >> endl;
}
anyone can write a simple progran like that, the question is, can you do it in O(log(n)) time?

Steve S - Good one!
Off the top of my head

include <iostream.h>
main{
int[10] n;

cout << "enter ten numbers" << endl;
for (int i = 0; i < 10; i+=2)
{
cin >> n[i]
}

int biggest = 99999, littlest = -999999;

for (int j = 0; j < 10; j++)
{
if n[j] < littlest
littlest = n[j]
else if n[j] < biggest
biggest = n[j]
}

int avg = biggest + littlest /2;
cout << avg >> endl;
}
yes, yes I can. Actually you know I was assigned to do the same assignment in my class, so no, no I wont. My services don't come free, you pay like everyone else.

BTW, it really doesn't take an expert to make a program that is that simple.
And you think I should do the learning for you why? And who will be there to do your work after graduation so you can file your nails, surf the web and pick up your paychecks for nothing? Do it yourself.
C'mon man do your own homework
the question is too difficult for an ordinary c++ expert. try mailing it to bill gates

Back to QA. TechInterviews.com. Powered by Yahoo! Answers and TechInterviews.com community.