Disini Projectnya

Pake Visual C++
Pake Dev C++



// Tugas_sort.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
// Tugas_sort.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <fstream>
#include <conio.h>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <string.h>
#ifdef _MSC_VER
#define getch() _getch()
#endif

using namespace std;

static int A[1000000];

int main (void) {
cout <<"\t============================================="<<endl;
cout <<"\n\t         PROGRAM SORTING SEDERHANA " << endl;
cout <<"\n\t============================================="<<endl;
cout <<"\n\t               dibuat oleh :" << endl;
cout <<"\n\t  Raditya Rimbawan Oprasto - 1411601550 " << endl;
cout <<"\n\t  Kirwanto - 1411601543 " << endl;
cout <<"\n\t  Mamat Solahudin -    1411601 26  " << endl;
cout <<"\n\t============================================="<< endl;
cout <<"\t     Please Enter Your Project In Here" << endl;
cout <<"\t       And Then This Process Is Start" << endl;
cout << "\n\t============================================="<<endl;
  getch();

char data_masuk[25] = "data.txt";
char data_keluar[25] = "dataurut.txt";

ifstream infile(data_masuk); //opening an input stream for file
    /*checking whether file could be opened or not. If file does not exist or don't have read permissions, file
  stream could not be opened.*/
 
if(infile.is_open())
    {
    //file opened successfully
    cout << "\n \t  - File opened successfully...";
   
    //time start
    int start_s=clock();
   
    //output file
    ofstream outfile;
    outfile.open(data_keluar);
   
    double angka;
    int i = 0;
    int N, j, x, kiri, kanan, tengah;   
   
    cout << "\n \t  - Reading data from file into array...";
    while(!infile.eof()) {   
            infile >> angka;
            double k = static_cast<double> (i);
            i++;
            }
    N=i-1;
   
    if (N > 0 )
    {
        //binary sort
        cout << "\n \t  - Sorting data, please wait...";
        for (i=1; i<N; i++)
        {
            x = A[i];
            kiri = 0;
            kanan = i-1;
           
            while (kiri<=kanan)
            {
                tengah = (kiri+kanan)/2;
                if ( x < A[tengah] )
                    { kanan = tengah-1;    }
                else
                    { kiri = tengah+1;    }
            }
           
            //melakukan pergeseran
            for (j=i-1; j>=kiri; j--)
                A[j+1] = A[j];
               
            //tempatkan data di kiri
            A[kiri] = x;
        }   
       
        //write data
        cout << "\n \t  - Write data...";
        for (i = 0; i<N ; i++) {
        outfile << A[i] << endl;
        }
       
        cout << "\n \t  - Done. " << endl;
       
        //time stop
        int stop_s=clock();
        int detik = (stop_s-start_s)/static_cast<int>(CLOCKS_PER_SEC);
        cout << "\n \t============================================="<<endl;
        cout << "\t Input Filename    : " << data_masuk <<endl;
        cout << "\t Output Filename   : " << data_keluar <<endl;
        cout << "\t Jumlah Baris Data : " << N << " baris" <<endl;
        cout << "\t Elapsed Time      : " << detik / 3600 <<" jam "<<( detik % 3600 ) / 60  <<" menit "<<( detik % 3600 ) % 60 << " detik" <<endl;
   
       
        }
        else // bila file tidak ada isinya
        {
            cout << "\n \t============================================="<<endl;
            cout << "\n \t            Warning: File Kosong !!!";
        }
        infile.close();
    }
    else //file could not be opened
    {
        cout << "\n \t============================================="<<endl;
        cout << "\n \t    Warning: File could not be opened !!!";
    }
   
getch();
return 0;
}