Simply open the program Turbo C + + or C + + other programs and inputkan code like this:------------------------------------------------------------------------------------------------------------------------------------
#include <conio.h> #include <iostream.h> main(){ int i,j,n,temp; int L[50]; cout<<"\n*Dengan syarat masukan nilai ke1, nilai ke2>ke1, nilai ke3<ke2 & nilai ke3>ke1* "; cout<<"\nJumlah data yang akan diurutkan = ";cin>>n; for(i=0;i<n;i++){ cout<<"Masukan Data ke-"<<i+1<<"= ";cin>>L[i]; } for (i=1;i<n;i++) { temp=L[i]; j=i-1; while(temp<=L[j]) { L[j+1]=L[j]; j=j--; } if((temp >= L[j])||( j=1)) L[j+1]=temp; else { L[j+1]=L[j]; L[j]=temp; } } cout<< ("\nSetelah Pengurutan : "); for(i=0;i<n;i++) cout<<" "<<L[i]; getch();}
------------------------------------------------------------------------------------------------------------------------------------
Good luck
0 komentar:
Post a Comment