Для заданного массива вычислить и напечатать величины A и n, где A - наибольший элемент массива, n - его порядковый номер.
Буду очень благодарен. если поможете!
C/C++
С++ Прошу помочь!
#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
#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;
}
#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;
}
#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
Саша Ефимов
позвольте усомниться в работе вашего алгоритма
Саня Гришуков
позволяю
Похожие вопросы
- Прошу помочь с С++!
- Рейтинг контроль. Прошу помочь
- Прошу помочь с двумя задачами по C++. Есть код моей попытки. Буду рад если напишите проги.
- Программирование C++ ПРОШУ ПОМОЧЬ!
- Знатоки ассемблера и си, плюсов прошу помочь
- Прошу, помогите пожалуйста с C++
- Прошу помогите написать код на c++, нужно сдать сегодня ?
- C++ Прошу помогите!!! \ Удалить столбец с номером К
- С++ Прошу помочь с задачей
- Прошу, помогите с написанием программы на С++