0% found this document useful (0 votes)
24 views4 pages

Tugas Besar Algoritma & Struktur Data Ii

This document is a thesis titled "TUGAS BESAR ALGORITMA & STRUKTUR DATA II" written by Indra Irawan, student number 10509149 of the Computer Science class of 2010 at the Faculty of Engineering and Computer Science, University of Computer Indonesia. It includes source code for an algorithm called selection sort to sort an array of integers in ascending order.

Uploaded by

Anisa Restiana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Tugas Besar Algoritma & Struktur Data Ii

This document is a thesis titled "TUGAS BESAR ALGORITMA & STRUKTUR DATA II" written by Indra Irawan, student number 10509149 of the Computer Science class of 2010 at the Faculty of Engineering and Computer Science, University of Computer Indonesia. It includes source code for an algorithm called selection sort to sort an array of integers in ascending order.

Uploaded by

Anisa Restiana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

TUGAS BESAR

ALGORITMA & STRUKTUR DATA II

Disusun Oleh :

Nama: Indra Irawan

Nim: 10509149

Kelas : Mi-4

MANAJEMEN INFORMATIKA

FAKULTAS TEKNIK DAN ILMU KOMPUTER

UNIVERSITAS KOMPUTER INDONESIA

2010
-Selection Sort

1. Source code

#include <iostream.h>

#include <conio.h>

int data[10],data2[10];

int n;

void tukar(int a, int b)

int t;

t = data[b];

data[b] = data[a];

data[a] = t;

void selection_sort()

int pos,x,y;

for(x=1;x<=n-1;x++)

pos = x;

for(y = x+1;y<=n;y++)

if(data[y] < data[pos]) pos = y;

if(pos != x) tukar(pos,x);

}
void main()

//masukan nilai

cout<<"\nMasukkan nilai : ";

cin>>n;

for(int x=1;x<=n;x++)

cout<<"\nMasukkan nilai ke "<<x<<" : ";

cin>>data[x];

data2[x]=data[x];

selection_sort();

cout<<"\n\n";

//tampilkan nilai

cout<<"nilai Setelah di Sort => ";

for( x=1;x<=n; x++)

cout<<" "<<data[x];

cout<<"\n\n Sorting Selesai";

getch();

}
1. Output

You might also like