A  program to remove the duplicate numbers using vectors by the user using a C++ programming language. The program will work on C++ 11 version.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGgThank you very much for your support

Program Listing

#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
	std::cout << "Remove duplicate numbers from vector in C++\n\n";
	std::cout << "How many numbers: ";
	int numberCount;
	std::cin >> numberCount;
	std::vector<int> numbers(numberCount);
	for (int i = 0; i < numberCount; ++i) {
        std::cout << "Give value in item no " << i+1 << " : ";
		std::cin >> numbers[i];
	}
	std::sort(numbers.begin(), numbers.end());
	auto newEnd = std::unique(numbers.begin(), numbers.end());
	numbers.resize(std::distance(numbers.begin(), newEnd));
	std::cout <<"\n\n";
	std::cout << "List of numbers that are not duplicate:\n";
	for(int num : numbers) {
		std::cout << num << " ";
	}
}

Leave a Reply

Your email address will not be published.