Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#pragma once

#include <iostream>
#include<cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <ctime>
using namespace std;
template<typename T, int size>
int getArrLength(T(&)[size]) { return size; }
template <typename T>
int getArrLength(T arr)
{
int length = sizeof(arr) / sizeof(T);
return length;
}
template <typename T>
void swap(T *a, T *b)
{
T temp = *a;
*a = *b;
*b = temp;
}
int randomInt(int min, int max)
{
return (min + (rand() % (max - min)));
}
vector<int> createRandomArrInt(int size, int min, int max)
{
srand(time(NULL));
vector<int> vec;
for (int i = 0; i <size; i++)
{
vec.push_back(randomInt(min, max));
}
return vec;
}
template <typename T>
void printVec(vector<T> vec)
{
for (int i = 0; i < vec.size(); i++)
{
cout << vec.at(i) << " ";
}
cout << endl;
}

You might also like