diff --git a/find_max.cpp b/find_max.cpp deleted file mode 100644 index 92e716b..0000000 --- a/find_max.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include -using namespace std; - -int main() { - setlocale(0, ""); - int n; - cout << "Введите размер массива n: "; - cin >> n; - - if (n <= 0) { - cout << "n должно быть положительным" << endl; - return 1; - } - - int *arr = new int[n]; - - srand(static_cast(time(0))); - for (int i = 0; i < n; ++i) { - arr[i] = rand() % 61 - 30; // значения в диапазоне [-30; 30] - } - - cout << "Array:\n"; - for (int i = 0; i < n; ++i) { - cout.width(4); - cout << arr[i]; - if ((i + 1) % 10 == 0) cout << endl; - } - if (n % 10 != 0) cout << endl; - - int maxValue = arr[0]; - int indexMax = 0; - for (int i = 1; i < n; ++i) { - if (arr[i] > maxValue) { - maxValue = arr[i]; - indexMax = i; - } - } - - cout << "max: " << maxValue << " index: " << indexMax << endl; - - delete[] arr; - return 0; -} - -