Showing posts with label Sorting. Show all posts
Showing posts with label Sorting. Show all posts

Wednesday, November 7, 2012

Sorting Menggunakan Bahasa C

Sorting dapat diartikan secara sederhana sebagai pengurutan suatu data di dalam sekumpulan data yang tidak terurut.
Coding :

#include <stdio.h> 
#include <stdlib.h> 
void tukarNilai(int *intA, int intB);
int main()
{
 int listAngka[20]={1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2};
 int swap, urutan;

 do{
 swap=0;
 for(urutan = 0; urutan <19; urutan++){

  if(listAngka[urutan] < listAngka[urutan+1]){
   tukarNilai(&listAngka[urutan], &listAngka[urutan+1]);
   swap=1;
  }
 }

 }while(swap == 1);

 for(urutan=0; urutan < 20; urutan++){
 printf("Nilai : %d, \n", listAngka[urutan]);
 }
 system("pause");
}

void tukarNilai(int *intA, int *intB){
 int tInt = * intA;
 *intA = *intB;
 *intB = tInt;
}
Video :

how to use shorting with in c programming

Dear Lecture
Name: Him Seanghon
Mayor: D4 TMD Batch6

This my video from youtube



This is my link : http://youtu.be/Fh-C-KWwico

Thanks.

Sorting in c programming

Name : Sean Vandet
Major : D4 TMD ITB Batch 6
Sorting in c programming
Sorting used to mean simply as massaging a data in one data set that don't most massage.
Address is the location in memory where the value of the variable is stored.
Pinter is a variable whose value is also an address.

#include <stdio.h>
#include <stdlib.h>
void swapValue (int *tIntA, int *tIntB);

int main() {
    int tListAngka[20] = {1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2};
    int tSwap;
    int tUrutan;
    //repeat and check statement
    do {
        tSwap = 0;
        //repeat tUrutan = 1 end process when tUrutan = 18
        for(tUrutan=0;tUrutan<19;tUrutan++)
        {
            if(tListAngka[tUrutan] < tListAngka[tUrutan+1])
            {
                //one varaible has address and value
                swapValue(&tListAngka[tUrutan], &tListAngka[tUrutan+1]);
                tSwap = 1;
            }            
        }
    } while(tSwap == 1); //exit do()
    //repeat statement for loop
    for(tUrutan=0;tUrutan<20;tUrutan++)
    {
        //tUrutan 0 - 18

        printf("Nilai : %d\n", tListAngka[tUrutan],&tListAngka[tUrutan]);
    }
    system("pause");

}

void swapValue (int *tIntA, int *tIntB)
{
    int tInt = *tIntA;
    *tIntA = *tIntB;
    *tIntB = tInt;
}


link to youtube
http://www.youtube.com/watch?v=W_CURNVZkJQ&feature=youtu.be

Tutorial Pemrograman C : Sorting

Berikut Video Tutorial Pemrograman C mengenai Sorting
link Video : http://youtu.be/7Eo-z7x_Xww
Source Code 
#include <stdio.h>
#include <stdlib.h>

void swapValue (int *tIntA, int *tIntB);
int main()
{
    int tListAngka[20] = {9,9,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2};
    int tSwap;
    int tUrutan;

do {
    tSwap = 0;
    for(tUrutan=0;tUrutan<19;tUrutan++)
    {
        if(tListAngka[tUrutan]<tListAngka[tUrutan+1])
        {
            swapValue(&tListAngka[tUrutan], &tListAngka[tUrutan+1]);
            tSwap = 1;
        }
    }
}
while(tSwap == 1);
for(tUrutan=0;tUrutan<20;tUrutan++)
{
    printf("Nilai : %d,\n", tListAngka[tUrutan]);
}
system("pause");
}
void swapValue (int *tIntA, int *tIntB)
{
    int tInt = *tIntA;
    *tIntA = *tIntB;
    *tIntB = tInt;
}

Terima Kasih ^_^

Shorting menggunakan bahasa C

Alhamdulilah tugas kali ini dapat selesai, dimana materi kali ini adalah shorting yang pada intinya adalah mengkelompokkan data atau nilai yang sama. Menggunakan Array dan pointer. Adapun scriptnya sbb:



#include <stdio.h>//library yg dibutuhkan
#include <stdlib.h>

void swapValue (int *tIntA, int *tIntB);

int main()
{
       int tListAngka[20] = {1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2};
       int tSwap;
       int tUrutan;

       do
       {
              tSwap = 0;
              for(tUrutan=0;tUrutan<19;tUrutan++)
              {
              if(tListAngka[tUrutan]<tListAngka[tUrutan+1])
                     {
                     swapValue(&tListAngka[tUrutan], &tListAngka[tUrutan+1]);
                     tSwap = 1;
                     }
              }
       }
       while(tSwap == 1);
       for(tUrutan=0;tUrutan<20;tUrutan++)
       {
              printf("Nilai : %d,\n", tListAngka[tUrutan]);
       }
       system("pause");
}

void swapValue (int *tIntA, int *tIntB)
{
       int tInt = *tIntA;
       *tIntA = *tIntB;
       *tIntB = tInt;
}

Vidionya dpt dilihat di: 

Sorting Pemograman C

Berikut tutorial melakukan pengurutan nilai dari yang besar ke yang kecil pada pemograman C. Pada tutorial ini kita akan mengurutkan nilai yang ada di dalam sebuah array dengan memanggil fungsi untuk pertukaran nilai. Fungsi tersebut akan dipanggil pada fungsi utama di dalam sebuah perulangan.
Berikut video tutorialnya :


Tuesday, November 6, 2012

Tutorial Sorting Pemograman C



Sorting dapat diartikan secara sederhana sebagai pengurutan suatu data di dalam sekumpulan data yang tidak terurut.




Adapun Video Youtube dapat dilihat disini

Sedangkan codingnya sebagai berikut :

#include <stdio.h>
#include <stdlib.h>

void swapValue (int *tIntA, int *tIntB);

int main()
{
       int tListAngka[20] = {1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2};
       int tSwap;
       int tUrutan;

       do

       {
              tSwap = 0;

              for(tUrutan=0;tUrutan<19;tUrutan++)

              {
                     if(tListAngka[tUrutan]<tListAngka[tUrutan+1])

                     {
                           swapValue(&tListAngka[tUrutan], &tListAngka[tUrutan+1]);

                           tSwap = 1;
                     }
              }
       }
      
       while(tSwap == 1);

       for(tUrutan=0;tUrutan<20;tUrutan++)

       {
              printf("Nilai : %d,\n", tListAngka[tUrutan]);
       }

       system("pause");
}

void swapValue (int *tIntA, int *tIntB)
{
       int tInt = *tIntA;
       *tIntA = *tIntB;
       *tIntB = tInt;
}

Semoga dapat bermanfa'at, Terimakasih.