Creating a program sorting numbers from small to large using C + +

This time I will discuss about programming C + +
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
SHARE

Alit Satya N.

Hi. I’m Video Editor. I'm StartUp Enthusiast, I'm Diecast Enthusiast, Blog Writer and Videographer/Photographer sometimes. Inspired to make my life looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 komentar:

Post a Comment