pls give me a hint or any idea on how i can solve my problem..tnx..

Recommended Answers

All 6 Replies

Get someone to read these numbers to you, and you try to remember what the highest and lowest numbers you hear.

31
47
85
64
95
48
45
86
26
61
47
76
98
80
62
19
4
12
10
78

Use a vector.

Use a vector.

"Without using an array" generally means "without storing all of the numbers", which means vector is out too. But even if you could store all of the numbers, doing so would be stupid because it's trivial to write a linear algorithm without wasting memory like that.

True enough. I assumed wrongly that it had more to do with setting a specific size of an array, with regards to allocation and things like that. Also, since the program isn't really asking for the set of data but only the largest and smallest out of those entered, it doesn't make sense.

Easy enough, assuming some things.

int maxVal  = INT_MIN;
int minVal = INT_MAX;
int input = -1;
const int END  = -1;
while( cin >> input ){
  if( input == END) break;
  else{
    minVal = std::min(minVal,input);
    maxVal = std::max(maxVal,input);
  }
}

And what do you suppose they might learn from that spoon-fed answer on a plate?

Don't give away code!
http://www.daniweb.com/software-development/cpp/threads/78223

All that's going to happen is they'll hand this in without having much of a clue, so that when next week's homework comes around (say sorting numbers), they're totally screwed (and back asking for more homework).

commented: Yep... +16
commented: Yes +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.