c++
include <iostream>
include <cmath>
using namespace std;
int main() {
int n;
cin>>n;
float a[n];
int num;
for (int i=0; i<n; i++) {
cin>>a[i];
if (i>0) {
if (abs(a[i])<abs(a[i-1])) num=i+1;
}
cout<<num;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
c++
include <iostream>
include <cmath>
using namespace std;
int main() {
int n;
cin>>n;
float a[n];
int num;
for (int i=0; i<n; i++) {
cin>>a[i];
if (i>0) {
if (abs(a[i])<abs(a[i-1])) num=i+1;
}
}
cout<<num;
return 0;
}