Skip to main content

vercetti322

User since Aug 27, 2024
1 Posts

Recent Posts

Untitled

Aug 27, 2024vercetti322

0 likes • 4 views

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
// Function to generate random numbers
vector<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 integers
void printVector(const vector<int>& vec) {
for (int num : vec) {
cout << num << " ";
}
cout << endl;
}
// Function to sort and display numbers
void sortAndDisplayNumbers(vector<int>& numbers) {
sort(numbers.begin(), numbers.end());
cout << "Sorted numbers: ";
printVector(numbers);
}
int main() {
// Seed the random number generator
srand(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 numbers
vector<int> numbers = generateRandomNumbers(count, minValue, maxValue);
// Display unsorted numbers
cout << "Unsorted numbers: ";
printVector(numbers);
// Sort and display sorted numbers
sortAndDisplayNumbers(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

Shared

Please Log In

You must be authenticated to view a user's shared posts

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

Forgot 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.