This is the best logic building program in C++ for beginners. The program is related to Array exercise. The program will find out the third largest number in the given array like e.g. Given array is [14 , 15 , 55 , 77 , 9] its third greatest will be [15].
Source Code
#include "stdafx.h"
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Enter your 10 numbers";
vector<int> numbers(10);
for(size_t n = 0; n < numbers.size(); ++n)
cin >> numbers[n];
nth_element(numbers.begin(), numbers.begin() + 2, numbers.end(),//we have used "#include <algorithm>" for the function nth_element
greater<int>());//we have used "#include <functional>" for the function greater<int>()
cout << "Third Largest number is " << numbers[2] << '\n';
system("PAUSE");
return 0;
}
Casinos Near You in Jordan 6-reels & 12-reels | Air Jordan
ReplyDeleteFind your next hotel stay near you in Jordan real air jordan 18 retro red suede 6-reels & 12-reels. All-around top air jordan 18 retro men blue top-rated 가입머니 지급 사이트 hotels air jordan 18 retro to you with world-class amenities, 배트맨토토 24/7 Casino and Spa and Casino.