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 is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

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 is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Kamis, 22 Oktober 2015

Pertemuan keenam

Kali ini membahas tentang Link List
 
Link List

#include <iostream>
using namespace std;

class Link{
public :
int data;
Link *next;
Link *back;

};



int main(int argc, char** argv) {
Link *a = new Link;
Link *b = new Link;
Link *c = new Link;
a->data = 1;
a->next = b;
b->data = 2;
b->next = c;
c->data = 3;
c->next= NULL;
cout<<a->next->data;
return 0;

}

Pertemuan kelima

Kali ini membahas tentang TDA(Tipe Data Abstrak)
 
A. Tipe Data Abstrak 1D Statis

# include <iostream.h>
# define maks 5
class Array1D {
friend ostream& operator<<(ostream&, const Array1D&);
friend istream& operator>>(istream&, Array1D&);
public :
            Array1D();
            void cetak();
            void geser_kiri();
            void geser_kanan();
private :
         char A[maks];

 };

void Array1D::cetak(){
          for (int i=0; i<maks; i++)
          cout << A[i] << " ";

  }

ostream& operator<<(ostream& out, const Array1D& x){
   for (int i=0; i<maks; i++){
          cout << x.A[i] << " ";
          cout << endl;
          return out;

   }

istream& operator>>(istream& in, Array1D& x){
    int posisi;
         cout << "Mengisi array pada posisi ke : ";
         in >> posisi;
         if (posisi > 0 && posisi <= maks) {
         cout << "Masukkan elemen array-nya : ";
         in >> x.A[posisi-1];
    }
      else
         cout << "Anda memasukkan posisi di luar range ... ";
      return in;
 }

voi d Array1D::geser_kanan(){
  int n = maks;
  int temp = A[n-1];
  f or (int i=n-1; i >= 0; i--)
  A[i+1] = A[i];
  A [0] = temp;
 }


void Array1D::geser_kiri(){
   int n = maks;
   int temp = A[0];
    for (int i=0; i < n; i++)
    A[i] = A[i+1];
    A[n-1] = temp;
 }


Main

main() {
   Array1D x;
   cout << "Array masih kosong : " << x;
   cin >> x;
   cout << "Isi Array saat ini : " << x;
   x.geser_kiri();
   cout << "Isi Array setelah digeser ke kiri : " << x;
   x.geser_kanan();
   cout << "Isi Array setelah digeser ke kanan : " << x;
   return 0;
}

Pertemuan keempat

Kali ini membahas Array

1. Array [Input & Output]

#include <iostream>
using namespace std;

class Arrq{
private:
int arr[9];
int i;
public:
void input(int i,int b){
if (i<b){
cout<<"Masukkan Array ";
cin>>arr[i];
input(i+1,b);

}

}
void output(int i,int b){


//for (int i=0;i<9;i++){
if (i<b){

cout<<arr[i]<<" ";
cout<<endl;
output(i+1,b);
}


}
};



int main(int argc, char *argv[]) {
Arrq a;
a.input(0,9);
cout<<endl;
a.output(0,9);


return 0;

}


2. Array [Mengubah baris menjadi kolom]

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
int arr[9]={1,2,3,4,5,6,7,8,9,};
int p=0;
cout<<"sebelum di tukar= \n";

for(int b=0;b<3;b++){
for(int h=0;h<3;h++){
cout<<arr[h+p]<<" ";

}cout<<endl;
p=p+3;
}
int q=0;
for (int c=0;c<9;c++){
if (arr [c]%3!=0){
int temp=arr[c];
arr[c]=arr[c+1];
arr[c+1]=temp;

}
}
cout<<"setelah di tukar = \n";
cout<<endl;
for(int i=0;i<3;i++){
for (int a=0;a<3;a++){
cout<<arr[a+q]<<" ";

}cout<<endl;
q=q+3;

}
return 0;

}

Pertemuan ketiga

Kali ini membahas Jenis-Jenis Perulangan da Array

1. 3 Jenis Perulangan C++


  • For
Mencetak bilangan 10 sampai 1.
Void cetaklah(int i, int j){
              int i=10;
              int j=1;

              for(i=10;i>=j;i--){
              cout<<i;
         
                }
  • Do...while
Mencetak bilangan 10 sampai 1.
void cetaklah(int i, int j){
            int i=10;
            int j=1;
         
            do{
                  cout<<i;
            }

            while(i>j){
                cout<<"Selesai";
            }

  • While

 Mencetak bilangan 10 sampai 1.
void cetaklah(int a, int b){
         int i=a;
         while(i>=b){
              cout<<" I = "<<i;
          }


2. Array

void masukandata(int A[], int n){
            for(int i=0;i<=n;i++){
               cout<<"Masukan Data ke"<<i+1;
               cin>>A[i];
             }

int jumlahkan(const int A[], int n){
     int total=0;
          for(int=0;i<n;i++){
             total += A[i];
             return total;
          }

Pertemuan kedua

Kali ini kita akan membahas struct dan class

1. Main

        #include <conio.h>
        #include <iostream.h>
        
        int main(){
                float bil1=0,bil2=0,jumlah;
           
                cout<<"Masukan Bilangan A : "; cin>>bil1;
                cout<<"Masukan Bilangan B : "; cin>>bil2;
                jumlah =bil1+bil2;
             
                cout<<"Jumlah "<<bil1<<" + "<<bil2<<" = "<<jumlah;
          getch();
        )

2. Fungsi
        void masukandata(float &bil1,float &bil2){
           
                cout<<"Masukan Bilangan A : "; cin>>A;
                cout<<"Masukan Bilangan B : "; cin>>B;
                jumlah =A+B;
         
        )
       float jumlahkan(float bil1,float bil2){
              float jumlah;
              jumlah=0;
              jumlah=bil1+bil2;
              return jumlah;
            }
      float tampilkan(float bil1,float bil2,jumlah){
           cout<<"Jumlah "<<bil1<<" + "<<bil2<<" = "<<jumlah;
           return jumlah;
       }
3. Struct
       Struct Bilangan{
                      float bil1;
                      float bil2;
            }
     Bilangan x;
     masukandata(x.bil1,x.bil2);
     float jumlah;
     jumlah=jumlah(x.bil1,x.bil2);
     tampilkan(x.bil1,x.bil2,jumlah);
    }

4. Class
       Class Bilangan{
             public:
                  void masukandata();
                  float jumlah();
                  void tampilkan();

            private:
                  float bil1;
                  float bil2;
                  float jumlah;
            }

             Bilangan x;
   
             x.masukandata();
             x.jumlah();
             x.tampilkan();

Pertemuan pertama

Pertemuan Pertama kali ini membahas perulangan

1. Perulangan For
        #include <conio.h>
        #include <iostream.h>
        
        int main(){
                  for(int i=1;i<10;i++){
                   cout<<i;
          }
          getch();
        )
2. Perulangan While
       #include <conio.h>
       #include <iostream.h>
       int main(){
               int i;
             while (i<=10){
                 cout<<i;
            }
          getch();
         }
3. Perulangan Do-while
       #include <conio.h>
       #include <iostream.h>
       int main(){
               int i;
             do{
                 cout<<i;
                i++;
            }
          while(i<=10)
          }
          getch();
         }
4. Fungsi
       #include <conio.h>
       #include <iostream.h>
       void main(){
         int hitung(int a, int b){
          total=0;
            for(int a=1;a<=b;a++){
                 total=total+1;
             return total;
           }       
          getch();
         }
5. Template (Fungsi)
           #include <conio.h>
           #include <iostream.h>
    
           void main(){
                      Template<Class T>
                        T hitung(T a, T b){
                           total=0;
                           for(T a=1;a<=b;a++)
                           total=total+1;
                           return total;
                        }
                       getch();
                   }
6. Fungsi Ganjil
          #include <conio.h>
          #include <iostream.h>
           void main(){
                       void ganjil(int a, int b){
                        for(a=1;a<=b;a++){
                            if(a%2!0){
                              cout<<a<<",";
                          }
                      getch();
                 }