Thread: C++ Help
View Single Post
  #2  
Old 04-21-2011, 11:48 PM
naez naez is offline
Banned


Join Date: Mar 2011
Location: s0cal
Posts: 629
Send a message via ICQ to naez Send a message via AIM to naez Send a message via MSN to naez Send a message via Yahoo to naez
Default

Those are actually simple, but I am too lazy to help you. When I am too lazy to do something, I post it on www.stackoverflow.com. The nerds there have done like 90% of my programming since they existed.

Just don't say it's HW, make up something.


---

For the first one I'd like store the five numbers in an array, then run them through min() and max() and through a for loop to do the average.


---


For the second one define the value of coins, then take the input int and just go through them.

Code:
#define QUARTER 25

// then in main():

int numquarters = 0, numdimes = 0;

int i;
cin >> i;

while ( i != 0)
{
      if (i >= QUARTER)
      {
          i -= QUARTER;
          numquarters++;
          continue;
      }
     // dimes etc fall thru
}

printf("Q=%d, D=%d, ...", numquarters, numdimes, ...);
sry lazy
Last edited by naez; 04-22-2011 at 12:00 AM..