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-lpOoIeJoh6gpJthPoGg
Thank 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 << " ";
}
}
Get home tutors near me in Singapore at your fingertips. Choosing the best and reliable Online tuition teacher in Singapore is not a difficult task when you have Ziyyara. We are an Edutech Company providing holistic education all over the globe which helps students to create a brighter tomorrow for themselves.
ReplyDelete