Posts

Showing posts with the label Algoritma & Pemrograman 2

Materi Algoritma dan Pemrograman 2

Sialhkan download materi Alpro 2 disini disni aja

Insertion_Sort_for_Practice

#include <iostream> #include <conio.h> using namespace std ; int data[10],data2[10]; int n; void tukar(int a, int b) {  int t;  t = data[b];  data[b] = data[a];  data[a] = t; } void insertion_sort() {  int temp,i,j;  for(i=1;i<=n;i++)  {   temp = data[i];   j = i -1;   while(data[j]>temp && j>=0)   {    data[j+1] = data[j];    j--;   }  data[j+1] = temp;  } } int main() {  cout<<"\t\t\t===PROGRAM INSERTION SORT===\n\n"<<endl;  //Input Data  cout<<"Masukkan Jumlah Data : ";  cin>>n;  cout<<"\n";  for(int i=1;i<=n;i++)  {   cout<<"Masukkan data ke "<<i<<" : ";   cin>>data[i];   data2[i]=data[i];  }  insertion_sort();  cout<<"\n\n";  //tampilkan data  cout<<"Data Setelah di Sort : ";  for(int i=1; i<=n; i++)  {   ...

Merge_n_Insertion_sorting

// include file #include <condefs.h> #include <conio> #include <iostream> #include <fstream> //dibatasi memori 52 #define MAXLIST 52 #define MAXINT (int) (2147483647) using namespace std; //struktur data kita tetap dan fleksible typedef char item_type; typedef struct node_tag; {   Item_type info;   struct node_tag *next; } Node_type; typdedef struct list_ag {   Node_type *head;   Node_type *tail; } List_type; //prototype fungsi operasi pada link list void AddNode(List_type* ,Item_type , const int opt=0); void DeleteNode(List_type , Item_type); void Error (char*); bool ExtractLine(Item_type& , Item_type); void InitList(List_type* ); Node_type *MergeSort(Node_type *p); List_type *InsertionSort (List_type *); bool FindItem(const List_type* ,Item_type); void Transverse(const List_type* ,void (*Visit) (ItemType)); void Visit(Item_type); char Menu(void); void CopyList(const List_type *, List_type *); void BatchSort(List_type *list_ptr); //var gl...
Well, here is the sample of TicTac game developed in Java, Ok, try to develop in C++. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TicTac2 implements ActionListener {     private int[][] winCombinations = new int[][] { { 0, 1, 2 }, { 3, 4, 5 },{ 6, 7, 8 },             { 0, 3, 6 },{ 1, 4, 7 }, { 2, 5, 8 },{ 0, 4, 8 }, { 2, 4, 6 }};     private JFrame window = new JFrame("Catur Jawa");     private JButton buttons[] = new JButton[9];     private int count = 0;     private String letter = "";     private boolean win = false;     private static int startCount = 0;     JMenuBar menu = new JMenuBar();     JMenuItem newGame = new JMenuItem("New Game"), instr = new JMenuItem(             "Instructions"), exit = new JMenuItem("Exit"), ...