   Stuck in vector exercise
  I am kind a stuck in a small vector problem. Here is the program.//. Write a program to report the length of the longest and shortest string in its input (yeap.. same old dilemma for newbies)I could manage to do the following code so far;####################################################include "stdafx.h"#include<iostream>#include<string>#include<algorithm>#include<vector>using namespace std;int main(){typedef vector<string> crt_vec;crt_vec words;cout << "Enter few words: " << endl;// ask words and put in vectorstring x;while(cin >> x){words.push_back(x);}sort(words.begin(),words.end());system("pause");}#######################################################I have no idea how I read the longest and shortest words from vector after sorting it. I think I should use "min" & "max". Can anyone tell me how can I use them.   
  You could introduce a custom sort function to the vector, which sorts based on the length of the string. After that the front will be the longest, the back will be the shortest, or vice versa depending on how you sort.;  Hum, I thought of a simple way to solve it using max and min like you mentioned, and you don't have to sort the vector.###########################################typedef string::size_type string_size;string_size maxlen = 0;for(int i = 0; i != words.size(); ++i)maxlen = max(maxlen, words.size());string_size minlen = maxlen;for(int i = 0; i != words.size(); ++i)minlen = min(minlen, words.size());###########################################Something like this, and you'll have your desired values in maxlen and minlen at the end.