Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline double area(double a, double h) {
- return (a * h) / 2;
- }
- unsigned int sum(unsigned int *arr, size_t size) {
- if (size > 0)
- return arr[size - 1] + sum(arr, size - 1);
- return 0;
- }
- unsigned int sum(unsigned int first, unsigned int step, unsigned int count) {
- if (count) {
- first += step;
- return first + sum(first, step, count - 1);
- }
- return 0;
- }
- unsigned int sum(unsigned int first, unsigned int step, unsigned int count) {
- if (count) {
- first += step;
- return first + sum(first, step, count - 1);
- }
- return 0;
- }
- float sum(float first, float step, unsigned int count) {
- if (count) {
- first += step;
- return first + sum(first, step, count - 1);
- }
- return 0;
- }
- double sum(double first, double step, unsigned int count) {
- if (count) {
- first += step;
- return first + sum(first, step, count - 1);
- }
- return 0;
- }
- template<class T, size_t SIZE = 0>
- void maximum(T arr[SIZE]) {
- size_t maxi = 0;
- for (size_t i = 0; i < SIZE; ++i) {
- if (arr[i] > arr[maxi])
- maxi = i;
- }
- T t = arr[0];
- arr[0] = arr[maxi];
- arr[maxi] = t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement