This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Welcome to our website. Neque porro quisquam est qui dolorem ipsum dolor.

Lorem ipsum eu usu assum liberavisse, ut munere praesent complectitur mea. Sit an option maiorum principes. Ne per probo magna idque, est veniam exerci appareat no. Sit at amet propriae intellegebat, natum iusto forensibus duo ut. Pro hinc aperiri fabulas ut, probo tractatos euripidis an vis, ignota oblique.

Ad ius munere soluta deterruisset, quot veri id vim, te vel bonorum ornatus persequeris. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.

Rabu, 29 Mei 2013

Praktikum ke-9 (Pnerapan Kombinatorik) Matdis

#include <cstdlib>
#include <iostream>
#include <stdio.h>

using namespace std;

int hasil;
//fungsi faktorial :
         int faktorial (int nilai)
         {
hasil = nilai;
while (nilai>1)
{
hasil = hasil * (nilai-1);
nilai = nilai - 1;
}
return hasil;
}

int main()
{
    int p, nq, max, x, i, j, n, k, r, s, tr, no;
    int a[100];
    div_t xx;
   
    for (i=0;i<100;i++){
        a[i] = 0;
        }
       
        //tampikan pembuka
        printf("---------------------------\nPROGRAM GENERATE PERMUTASI\n\n");
        printf("            Oleh Noviyan Aziz.\n");
        printf("---------------------------\n");
       
        //input nilai n ( Jumlah data < maksimal 100>)
        printf("Masukkan nilai n : ");
        scanf("%d", &n);
       
        //input array ke dalam array
        for(i=1;i<=n;i++){      //ulangi untuk semua data hingga data ke n
        printf("masukkan nilai himpunan a[%d] : ", i);
        scanf("%d", &a[i]);
        }
       
        //input nilai r
        printf("nilai r : "); scanf("%d", &tr);
       
        //hitung nilai permutasi
        p = faktorial(n);
        nq = faktorial(n=tr);
        if (nq==0) nq=1;
        max = p/nq;
        printf("nilai permutasi : %d\n \
        Tekan Enter untuk melihat hasil generate permutasi...\n",max);
       
      
        no=1; //variabel untuk menampilkan nomor
        //men-generate permutasi dengan algoritma generate next-permutation
       
        //generate sebanyak nilai permutasi
        for(x=1;x<=max;x++){
        printf("%3d", no);
        for(i=1;i<=tr;i++)
        printf("%d ", a[i]);
        printf("\n",a[i]);
        no++;
       
        j = n - 1;
        while (a[j] > a[j+1])
        j=j-1;
        k=n;
        while(a[j]>a[k])
        k=k-1;
       
        //tukar aj dan ak
        i=a[k];
        a[k]-a[j];
        a[j]=i;
       
        r=n;
        s=j+1;
        while(r>s){
                   //tukar ar dan as
        i=a[r];
        a[r]=a[s];
        a[s]=i;
       
        r=r-1;
        s=s+1;}
        }
       
    system("PAUSE");
    return EXIT_SUCCESS;
}

Senin, 29 April 2013

belom