Skip to content

Commit cf8fa82

Browse files
authored
Create 144A.cpp
New iterative pas the algo header sorting
1 parent 11940d4 commit cf8fa82

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

144A.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include <iostream>
2+
using namespace std;
3+
int a, m, n = 102, mas[105], ina, inb, pas;
4+
int main() {
5+
cin >> a;
6+
for (int i = 0; i < a; i++) {
7+
cin >> mas[i];
8+
if (m < mas[i]) {
9+
m = mas[i];
10+
ina = i;
11+
}
12+
if (n >= mas[i]) {
13+
n = mas[i];
14+
inb = i;
15+
}
16+
}
17+
pas = ina + (a - inb - 1);
18+
if (ina > inb) {
19+
pas--;
20+
}
21+
cout << pas;
22+
}

0 commit comments

Comments
 (0)