vercetti322
User since Aug 27, 2024
1 Posts
Recent Posts
#include <iostream>#include <vector>#include <algorithm>#include <cstdlib>#include <ctime>using namespace std;// Function to generate random numbersvector<int> generateRandomNumbers(int count, int minValue, int maxValue) {vector<int> numbers;for (int i = 0; i < count; ++i) {numbers.push_back(rand() % (maxValue - minValue + 1) + minValue);}return numbers;}// Function to print a vector of integersvoid printVector(const vector<int>& vec) {for (int num : vec) {cout << num << " ";}cout << endl;}// Function to sort and display numbersvoid sortAndDisplayNumbers(vector<int>& numbers) {sort(numbers.begin(), numbers.end());cout << "Sorted numbers: ";printVector(numbers);}int main() {// Seed the random number generatorsrand(static_cast<unsigned int>(time(0)));int count, minValue, maxValue;cout << "Enter the number of random numbers to generate: ";cin >> count;cout << "Enter the minimum value: ";cin >> minValue;cout << "Enter the maximum value: ";cin >> maxValue;// Generate random numbersvector<int> numbers = generateRandomNumbers(count, minValue, maxValue);// Display unsorted numberscout << "Unsorted numbers: ";printVector(numbers);// Sort and display sorted numberssortAndDisplayNumbers(numbers);return 0;}
Post Statistics
Posts
No Posts Found
It looks like vercetti322 has no public posts
Likes
Please Log In
You must be authenticated to view a user's likes
Profile Privacy
Multi-Factor Authentication
Multi-Factor Authentication (MFA) is an authentication method that requires you to provide two or more verification factors to gain access to your account. In addition to username and password, MFA requires you to verify your email on every login, which decreases the likelihood of someone stealing your account.
Change Password
Identity Color
Changes the color of your profile icon and cursor highlight in the live code editor. You and other users will be able to view this change.
Delete Account
Deleting your account is permanent. All data associated with your account will be lost.