Hi dev, this time I want to share some memories from when I was still in college, a little historical legacy, namely the results of a programming algorithm assignment, where at that time we were asked to sort rows of random numbers.
Oh yeah guys, this is because I no longer use Windows and no longer use Borland C++, so I adjusted the code to be able to run the online compiler
/******************************************************************************
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 j, x;
int larik [10] = {10, 5, 12, 0, 32, 56, 34, 6, 11, 99};
cout << "Data sebelum diurutkan: " << endl;
cout<< " ";
for(int i=0; i<10;i++)
cout << larik[i] <<" ";
cout <<endl;
for (int i=1;i<10;i++){
x=larik[i];
j=i-1;
while (x<larik[j]){
larik[j+1] = larik[j];
j--;
}
larik[j+1]=x;
cout<<endl;
cout<< i << " -> " ;
for(int z=0; z<10; z++){
cout<<larik[z]<<" ";
cout<<endl;
}
cout << endl;
cout << "Data setelah diurutkan: "<< endl;
cout<<" ";
for(int i=0;i<10;i++)
cout<<larik[i] <<" ";
}
}