AncientGigas

RezpectBlog - Program Simple Sorting (Pengurutan Data) C++

Apr 9th, 2019
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm> //library untuk fungsi pengurutan data
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     int arr[6] = {7,4,2,-1,-3,5}; //array data acak yang akan diurutkan
  8.     int temp;
  9.  
  10.     sort(arr+0, arr+6); //pengurutan data dengan fungsi dari library <algorithm>
  11.    
  12.     cout<<"Hasil pengurutan : ";
  13.     for(int x=0;x<6;x++){
  14.         cout<<arr[x]<<", "; //output hasil pengurutan
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment