#include <iostream>
using namespace std;
int main() {
float arr[10] = {1.0f, 2.0f, 3.0f, 0.0f, 0.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f};
float max = arr[0];
int index = 0;
for(int i = 1; i<10; ++i) {
if(arr[i]>max) {
max = arr[i];
index = i;
}
if(index>1&&arr[index-1]==0&&arr[index-2]==0) {
for(int i = 0; i<10; ++i) {
arr[i]=arr[i]*2;
cout << arr[i] << " ";
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main() {
float arr[10] = {1.0f, 2.0f, 3.0f, 0.0f, 0.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f};
float max = arr[0];
int index = 0;
for(int i = 1; i<10; ++i) {
if(arr[i]>max) {
max = arr[i];
index = i;
}
}
if(index>1&&arr[index-1]==0&&arr[index-2]==0) {
for(int i = 0; i<10; ++i) {
arr[i]=arr[i]*2;
}
}
for(int i = 0; i<10; ++i) {
cout << arr[i] << " ";
}
}