Selasa, 05 Juli 2011

class sorting

This sorting form jeliot, can be compared in the form c + + or dev, and if during use dev c + + or difficulty in understanding it in the form of this jeliot can help you understand it,,,

import jeliot.io.*;
public class sorting {
    public static void main() {
       int a[]=new int[10];
int cur,z,temp;
 System.out.print("Masukan Data");
        z=Input.readInt();
        for(int i=0;i<z;i++)
        {
            System.out.println("Data["+ i +"]:");
            a[i]=Input.readInt();
        }
        for(int i=0;i<z;i++)
        {
            cur=i;
            for(int k=i+1;k<z;k++)
            {
                if(a[cur]>a[k])
                {cur=k;}
            }
        temp=a[i];
        a[i]=a[cur];
        a[cur]=temp;
        }
        for(int i=0;i<z;i++)
        {
            System.out.print(a[i]);
        }
        for(int i=0;i<z;i++)
        {
            cur=i;
            for(int k=i-1;k<z;k++)
            {
                if(a[cur]<a[k])
                {cur=k;}
            }
        temp=a[i];
        a[i]=a[cur];
        a[cur]=temp;
        }
        for(int i=0;i<z;i++)
        {
            System.out.println();
            System.out.print(a[i]);
        }
    }
}


Tidak ada komentar:

Posting Komentar