Postingan

Menampilkan postingan dari 2014

walpaper militer

Gambar

program algoritma djikstra

#include <cstdlib> #include <iostream> #define max 20 #define infinity 9999 using namespace std; class dijkstra{       private:               int n;               int graph[max][max];               int colour[max];               int start;               int distance[max];               int predecessor[max];               enum {green,yellow,red};       public:              void read_graph();     ...

Program Algoritma Prim

#include <cstdlib> #include <iostream> using namespace std; class prims { private: int n; //no of nodes =>tidak ada node int graph_edge[250][4]; //edges in the graph =>tepi dalam grafik int g; //no of edges in the graph => tidak ada dari tepi dalam grafik int tree_edge[250][4]; //edges in the tree =>  tepi di pohon int t; //no of edges in the tree => tidak ada tepi di pohon int s; //source node =>node sumber //Partition the graph in to two sets => Partisi grafik ke dua set int T1[50],t1; // Set 1 int T2[50],t2; // Set 2 public: void input(); int findset(int); void algorithm(); void output(); }; void prims::input() { cout<<"*************************************************\n" <<" program implements the prims algorithm \n" <<"*************************************************\n"; cout<<"Enter the no. of nodes in the undirected weighted graph/"<<endl; cout<<"Masukkan no tersebu...

Program Fractional Knapsack

#include <cstdlib> #include <iostream> using namespace std; void SolveFract(int p[], int w[], float W, int n, int x[], float &TotalUntung){      int i;      float kapasitas;      bool MasihMuatUtuh;           for(i=0;i<n;i++){                       x[i];                       }      kapasitas = W;      TotalUntung = 0;      i = 0;      MasihMuatUtuh = true;      while ((i < n) && (MasihMuatUtuh)){            if (w[i] <= kapasitas){             ...

Fractional Knapsack 2 (struct)

#include <cstdlib> #include <iostream> using namespace std; struct knapsack{ float p,w,pw,x; //profit,berat,nilai dari p/w,nilai probabilita barang yang masuk char barang; } void swap(T *c,int i,int j){ T temp; temp=c[j]; c[j]=c[i]; c[i]=temp; return;} void Pengurutan(knapsack c[], int n){ for(int i=0;i<=n;i++){ for(int j=0;i<=n;i++){ if(c[i].pw tukar(c[i],c[j]; } } } void SolveFractorialKnapsack(knapsack c[], float w, int n,float  &TotalUntung){ int i; float kapasitas; bool MasihMuatUtuh; for (i=0;i<=n;i++){ c[i].x=0; } kapaitas=W; TotalUntung=0; i=1; MasihMuatUtuh=true; while ((i<=n) && (MasihMuatUtuh)){ if(c[i].w<=kapasitas){ c[i].x=1; totalUntung = totalUntung + c[i].p; kapasitas = kapaitas - c[i].w; i++ } else{ MasihMuatUtuh=false; } } if(i<=n){ c[i].x=kapaitas/c[i].w; totalUntung = totalUntung+c[i].x*c[i].p; } } int main(int argc, char *argv[]) { float c[100]; int n,W; //kapaistas char j=0; cout<<"Jumlah barang: "; cin>...

Fractional Knapsack 1

#include <cstdlib> #include <iostream> using namespace std; void SolveFractionalKnapsack(int p[], int w[], float W, int n, int x[], float TotalUntung){      int i;      float kapasitas;      bool MasihMuatUtuh;           for(i=1;i>n;i++){                       x[i];                       }      kapasitas = W;      TotalUntung = 0;      i = 1;      MasihMuatUtuh = true;      while ((i <= n) && (MasihMuatUtuh)){            if (w[i] <= kapasitas){           ...

MENWA

Gambar

MENWA

Gambar

PROGRAM C++ PENJADWALAN PELANGGAN

#include <cstdlib> #include <iostream> using namespace std; struct pelanggan{        int waktu,id;        }; void penjadwalanPelanggan(pelanggan p[], int a){         int i,j,temp,tukar;         //tukar = 1;         for(i=1; i< a-1 && tukar; i++){         //tukar = 0;         for (j=a; j<i+1; j--)         if (p[j].waktu < p[j-1].waktu){              //tukar = 1;              temp = p[j].waktu;              p[j].waktu = p[j-1].waktu;              p[j-1].waktu ...

PROGRAM PENCOCOKAN STRING

#include <cstdlib> #include <iostream> using namespace std; void FungsiGagal(char P[], int F[],int m){     int i,j;     F[0]=0;      j=0; i=1;     while(i<m){         if(P[i]==P[j]){             F[i]=j+1;             i++;             j++;         }else if(j>0){             j=F[j-1];         }else {             F[i]=0;             i++; } }  } int pencocokan(char T[], char P[]){     int i,j,F[100];     int m=strlen(P);     int n=st...