sorting ascending c++

This item was filled under [ c++ ]

Langsung saja. Program ini saya buat juga sebagai pengingat saya juga dasar coding c++  :D #maklum pelupa

ini menggunakan buble sort untuk sorting ascending dengan c++. Semoga bisa membantu :shakehand2

here the code :

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream .h>
#include <conio .h>
main()
{
int n, i, j, swap;
int a[100];
cout< <\n Jumlah data yang akan diurutkan : ; cin>>n;
for (i=0;i<n ;i++)
{
    cout<<\n Data Ke-<<(i+1)<<: ;
    cin>>a[i];
}
for(i=0; i< =n-1; i++)
{
    for(j=i+1; j<n; j++)
    {
        if(a[i]>a[j])
        {
            swap = a[i];
            a[i] = a[j];
            a[j] = swap
        }
    }
}
cout< <\n*********************************************************;
cout<<\nSetelah diurutkan : ;
for (i=0;i<n;i++)
cout<< <<a[i];
cout<<\n*********************************************************;
getch();
}

Tagged with: [ ascending, kuliah, program c, sorting ]
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera