Индексом числа 2 будет 4
Так как счёт идёт от нуля.
Вот пример кода на с++
#include <iostream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
using namespace std;
int main(){
setlocale(LC_ALL, "Russian");
const int N=6;
int array[N] = {-19,28,0,-4,2,13};
int Index =0;
int i;
for(i=0;i<N;i++)
{
cout << setw(5)<< array[i];
}
cout<< endl;
if(array[i] < Index)
Index=i;
cout<< "Индекс числа два: "<< Index;
Поделитесь своими знаниями, ответьте на вопрос:
Дан одномерный массив -19 28 0 -4 2 13 значение элемента массива 2 Индекс значения ?
Индексом числа 2 будет 4
Так как счёт идёт от нуля.
Вот пример кода на с++
#include <iostream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
using namespace std;
int main(){
setlocale(LC_ALL, "Russian");
const int N=6;
int array[N] = {-19,28,0,-4,2,13};
int Index =0;
int i;
for(i=0;i<N;i++)
{
cout << setw(5)<< array[i];
}
cout<< endl;
for(i=0;i<N;i++)
{
if(array[i] < Index)
Index=i;
}
cout<< "Индекс числа два: "<< Index;
}