![]() |
|
#1
|
|||
|
|||
"max" syntaxWhat does the "max" syntax do in the following statement?
c[i] = max(a[i], b[i]) I'm trying to figure out my homework for my comp sci class and the teacher sucks, so any help would be great. |
|||
|
#2
|
|||
|
|||
Re: "max" syntaxQuote:
Not sure what you meant by max syntax. But i guess your teacher might have been using the max function in STL algorithm. From what you posted the element c[i] gets assigned the bigger of the two values of a[i] or b[i]. Best of luck with the home work , study hard |
|
#3
|
|||
|
|||
Re: "max" syntaxThanks dude. So "max" actually does seperate which ever one is bigger? I didn't remember reading anything about "max" in the syntax chapter so I was a concerned.
|
|
#4
|
|||
|
|||
Re: "max" syntaxhttp://www.cplusplus.com/reference/algorithm/max.html
If you see functions like that that you don't understand, you probably want to use the above site. It's pretty handy. |
|
#5
|
|||
|
|||
Re: "max" syntaxQuote:
check whether he has used a #include <algorithm> if yes then this is the function, look at the examples given in the link below to get an idea http://www.cplusplus.com/reference/algorithm/max.html But may be he just defined the function max as a regular function or as a macro. check where else you can find max() in the code |
|
#6
|
|||
|
|||
Re: "max" syntaxQuote:
I tried running the sample program on this website. However It kept telling me "max" is an "undeclared identifier." I'm not sure what this means so if you can keep helping me through this that would be great. |
|
#7
|
|||
|
|||
Re: "max" syntaxQuote:
have you copied the entire program including the following lines? CPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Re: "max" syntaxyeah I did... I was able to run the sample "max" program from pico/g++ on my school's libra machine though (not on Microsoft visual though).
|
|
#9
|
|||
|
|||
Re: "max" syntaxCPP / C++ / C Code:
This works fine for me. Visual Studio 2008. Copy and paste your code. |
|
#10
|
|||
|
|||
Re: "max" syntaxQuote:
One of those things that is missing is the std::max function from <algorithm> (It is, however, implemented as a macro in the non-standard header <windows.h>.) There are free downloads of Microsoft compilers. If you are going with Microsoft, I would definitely recommend a current version of Visual Studio Express for learning C++ rather than the buggy old, bewhiskered Version 6 I would start here: http://www.microsoft.com/express/ and follow all instructions. It's kind of lengthy, but you will have the "best" that Microsoft can offer for free. If you are not running Version 6, tell us exactly what version you are using. Regards, Dave |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linked Lists advice request | promsan | C Programming Language | 74 | 23-May-2007 09:29 |
| Syntax question | Despoina | C++ Forum | 3 | 11-Jul-2006 02:16 |
| syntax errors in document | coder | MS Visual C++ / MFC Forum | 0 | 11-Mar-2006 05:12 |
| Winsock error when compiling FLTK 2.0 Projects | mauriciorossi | FLTK Forum | 3 | 16-Aug-2005 11:18 |
| Help with syntax errors | PeteGallo | C Programming Language | 7 | 08-Aug-2005 21:30 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The