Добавил:
wso_studf
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#include <iostream>
#include <cmath>
using namespace std;
double recursion(const double &z){
return z*z - 81;
}
double half_division(const double &a, const double &b, const double &eps){
double cut = (a + b) / 2;
if ((fabs(recursion(a) - recursion(b)) <= eps) || (fabs(recursion(cut)) <= eps))
return (a + b) / 2;
if (recursion(a) * recursion(cut) <= 0.0)
half_division(a, cut, eps);
else
half_division(cut, b, eps);
}
int max_index(int arr[], int array_size){
static int max = 0;
static int currIndex = 0;
static int memIndex = 0;
if (array_size){
if (*arr > max){
max = *arr;
memIndex = currIndex;
}
currIndex++;
return max_index(++arr, --array_size);
}
return memIndex;
}
int main(){
setlocale(LC_ALL, "rus");
cout << "Вариант №3" << endl;
cout << "Лабораторная работа №13" << endl;
const double a = -1;
const double b = 10;
const double eps = 0.001;
cout << half_division(a, b, eps) << endl;
int arr[] = {0, 19, 4, 75, 8, 1024, 22, 14, 6, 900};
int n = sizeof(arr) / sizeof(arr[0]);
cout << "\nИндекс максимального элемента в массиве = " << max_index(arr, n) << endl;
return 0;
}
Соседние файлы в папке 2 курс - Основы алгоритмизации _ вариант 3