-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.cpp
More file actions
30 lines (26 loc) · 696 Bytes
/
2.cpp
File metadata and controls
30 lines (26 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
using namespace std;
int main()
{
int arr[] = {0, 1, 2, 3, 4, 5};
int idx = 6;
int j = (idx * 2) - 1;
cout << j << endl;
for (int i = 11; i >= 0; i -= 2)
{
idx -= 1;
arr[i] = arr[idx];
arr[i - 1] = arr[idx];
// cout << i << " " << i - 1 << " ";
// for (int i = (idx * 2) - 1; i >= 0; i--)
cout << "arr[" << idx << "] = " << arr[idx] << " " << endl;
cout << "arr[" << i << "] = " << arr[i] << " " << endl;
cout << "arr[" << i - 1 << "] = " << arr[i - 1] << " " << endl;
cout << "=================" << endl;
}
cout << endl;
idx = 6;
for (int i = (idx * 2) - 1; i >= 0; i--)
cout << arr[i] << " ";
cout << endl;
}