C/C++

С++ Прошу помочь!

Для заданного массива вычислить и напечатать величины A и n, где A - наибольший элемент массива, n - его порядковый номер.

Буду очень благодарен. если поможете!
NM
Nurken Moldashev
385
 #include  
#include
using namespace std;
int main() {
cout > count;
auto box = new int[count];
cout > box[i];
auto pa = max_element(box, box + count);
auto a = *pa;
cout
Давид Постарниченко
Давид Постарниченко
76 489
Лучший ответ
#include <windows.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char **argv)
{
system("chcp 1251 > nul"); // Руссификация сообщений
setlocale(LC_ALL, "Russian");

int arr[10] = {-2, 0, 4, 6, 9, 3, 4, -3, 8, 6};
int i= 0; while (i<10) { cout << arr[i] << '\t'; i++; }
cout << endl << endl;

i= 1; int m= 0;
while (i<10)
{
if (arr[i]>arr[m]) m= i;
i++;
}

cout << "Максимальный элемент = " << arr[m] << " в позиции " << m << endl;
system("pause"); // system("pause > nul");
return 0;
}
Саша Ефимов
Саша Ефимов
21 700
 #include  

using namespace std;

int main() {
// Declare variables
int A = 0; // Largest element
int n = 0; // Ordinal number of largest element
const int SIZE = 10; // Size of array
int arr[SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Sample array

// Find the largest element and its ordinal number
for (int i = 0; i < SIZE; i++) {
if (arr[i] > A) {
A = arr[i];
n = i;
}
}

// Print the result
cout
Саша Ефимов позвольте усомниться в работе вашего алгоритма