| | |
c++ vectors using push_back
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
hi all,
I'm new to site {nice work on the forum
} and to c++ in general. I've started a class in the subject not to long ago and have hit a snag on one of the programing projects i was asigned to do ... I just cant figure this out ...
basicly i'm buildin a code that'll allow me to take some numbers that a user will enter and spit out the smallest, largest and average of the group. this has to be done using the push_back function that'll insert into vector objects.
Now i've figured out how to calculate average, and how to write the codin for the user to enter the numbers, I just haven't got a clue how i can make the code display the smallest and largest numbers of what the user enters ... i mean how can i make c++ determin which of em is smallest and which is largest ???.
the numbers can be anythin from negative to positve ...
if someone can help me out or point me in a direction of some info for this it be much appreciated ...
I'm new to site {nice work on the forum
} and to c++ in general. I've started a class in the subject not to long ago and have hit a snag on one of the programing projects i was asigned to do ... I just cant figure this out ...basicly i'm buildin a code that'll allow me to take some numbers that a user will enter and spit out the smallest, largest and average of the group. this has to be done using the push_back function that'll insert into vector objects.
Now i've figured out how to calculate average, and how to write the codin for the user to enter the numbers, I just haven't got a clue how i can make the code display the smallest and largest numbers of what the user enters ... i mean how can i make c++ determin which of em is smallest and which is largest ???.
the numbers can be anythin from negative to positve ...
if someone can help me out or point me in a direction of some info for this it be much appreciated ...
Use min_element and max_element functions
http://www.cppreference.com/cppalgor...x_element.html
http://www.cppreference.com/cppalgor...n_element.html
http://www.cppreference.com/cppalgor...x_element.html
http://www.cppreference.com/cppalgor...n_element.html
The key to eliminating bugs from your code is learning from your mistakes.
•
•
•
•
Now i've figured out how to calculate average, and how to write the codin for the user to enter the numbers, I just haven't got a clue how i can make the code display the smallest and largest numbers of what the user enters
*Voted best profile in the world*
•
•
•
•
Originally Posted by iamthwee
I'd bet your prof will want to write your own function to do that.
... and i'm planin on doin that but i just needed a point in the right direction as to how ... been that i never seen it done i needed a refrence to build my own ...I wouldnt just copy somones work cause thats not me ...
thats one of the reasons y i didnt post up the code cause i didnt need someone to solve this for me i just needed a boost in where to look into ...
anyways thx for the info help it def. was alot more then i expected :mrgreen: ...
Last edited by blazinking; Aug 2nd, 2006 at 10:08 am.
•
•
•
•
Originally Posted by blazinking
I wouldnt just copy somones work cause thats not me ...
thats one of the reasons y i didnt post up the code cause i didnt need someone to solve this for me i just needed a boost in where to look into ...
anyways thx for the info help it def. was alot more then i expected :mrgreen: ...
バルサミコ酢やっぱいらへんで
![]() |
Similar Threads
- What are vectors? (C++)
- vectors and classes (C++)
- Using two vectors? (C++)
- Using Vectors and Arrays with fstream (C++)
- minor problem with vectors and OOP (C++)
- Vectors, Functions, and Sorting... oh my! (C++)
- 6 Line class -> Me pounding head into wall (C)
Other Threads in the C++ Forum
- Previous Thread: who can help me in c++ project
- Next Thread: help with sorting program
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






