Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whladi1m/smplt.h
smplt.h - mini-library that includes simple things like sorting
https://github.com/whladi1m/smplt.h
Last synced: about 2 months ago
JSON representation
smplt.h - mini-library that includes simple things like sorting
- Host: GitHub
- URL: https://github.com/whladi1m/smplt.h
- Owner: whladi1m
- Created: 2024-05-11T06:18:11.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-15T16:35:38.000Z (7 months ago)
- Last Synced: 2024-05-16T05:18:09.053Z (7 months ago)
- Language: C++
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# smplt.h - Simple Mini Library
`smplt.h` is a lightweight C++ library providing simple functionalities like sorting algorithms, factorial calculation, finding roots of functions, and generating random numbers and vectors.
## Functions:
### Sorting Algorithms:
1. **Bubble Sort**: Sorts a vector of elements in ascending order using the Bubble Sort algorithm.
```cpp
#include "smplt.h"
#includeint main() {
std::vector numbers = {5, 2, 7, 3, 9, 1};
smplt::bubbleSort(numbers);
for (int num : numbers) {
std::cout << num << " ";
}
std::cout << std::endl;
return 0;
}
```
2. **Selection Sort**: Sorts a vector of elements in ascending order using the Selection Sort algorithm.
```cpp
#include "smplt.h"
#includeint main() {
std::vector numbers = {5, 2, 7, 3, 9, 1};
smplt::selectionSort(numbers);
for (int num : numbers) {
std::cout << num << " ";
}
std::cout << std::endl;
return 0;
}
```
### Math:
3. **Factorial**: Finds fib. numbers.
```cpp
#include "smplt.h"
#includeint main() {
int n = 5;
std::cout << "Factorial of " << n << " is: " << smplt::factorial(n) << std::endl;
}
```
4. **Find root of number**: Finds root of number.
```cpp
#include "smplt.h"
#includeint main() {
double root = smplt::findRoot([](double x) { return x * x - 4; }, 0, 3);
std::cout << "Root of the function f(x) = x^2 - 4 is: " << root << std::endl;
}
```**MORE EXAMPLES IN MAIN.CPP**