Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int a[n];
- int indexMin = 0, amountMin;
- cin >> a[0];
- amountMin = a[0];
- for(int i = 1; i < n; i++){
- cin >> a[i];
- if(a[i] < amountMin){
- amountMin = a[i];
- indexMin = i;
- }
- }
- int b;
- b = a[0];
- a[0] = a[indexMin];
- a[indexMin] = b;
- for(int i = 0; i < n; i++){
- cout << a[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement