Tuesday, December 18, 2012

Dasar-dasar Pemrograman : Membuat Matrik Diagonal

#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
int i, j;
int Matriks[100][100];
cout<<"\n\t"<<char(5)<<" Program Cek Matrik Diagonal 3x3 "<<char(5)<<endl<<endl;
cout<<"Nama  : Mamat Aji"<<endl;
cout<<"Nim   : 12018057"<<endl;
cout<<"Kelas : B"<<endl<<endl;
cout<<"Matrik ordo 3x3\n"<<endl;
cout<<"0 0 0"<<endl;
cout<<"0 0 0 "<<endl;
cout<<"0 0 0"<<endl<<endl;
cout<<"Input Matriks :\n";  
for(i=1; i<=3; i++){
for(j=1; j<=3; j++){
cout<<"Baris "<<i<<", Kolom "<<j<<" : ";
cin>>Matriks[i][j];
}}
cout<<endl;
cout<<"Hasil : \n"<<endl;
for(i=1; i<=3; i++){
for(j=1; j<=3; j++){
cout<<Matriks[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
if(Matriks[i=0][j=0] == 1){
if(Matriks[i=0][j=0] == 1){
if(Matriks[i=0][j=0] == 1){
cout<<"==> Keterangan : Bukan Matriks Diagonal!!! "<<char(1)<<endl;
}}}   
else{cout<<"==> Keterangan : Matriks Diagonal..."<<endl;}
cout<<endl;   

system("PAUSE");
return EXIT_SUCCESS;
}

Tuesday, December 4, 2012

Dasar-dasar Pemrograman : Membuat Segitiga Bintang


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
                int i,j,k,n;

cout<<"Masukkan Angka Untuk Gambar Segitiga :";
cin>>n;
cout<<endl;
for (i=n;i>=0;i--)
{
for(j=i;j>=0;j--)
{
cout<<" ";
}
for(k=0;k<=n-i;k++)
{
cout<<"*";
}
for(k=0;k<n-i;k++)
{
cout<<"*";
}
cout<<endl;
}
                system("pause");
                return 0;
}

Dasar-dasar Pemrograman : Program Array


#include <cstdlib>
#include <iostream>

using namespace std; 

int main(int argc, char *argv[])
{  
    int matrix[2][2];
    int i,j;
    for(i=0;i<=1;i++){
                      for(j=0;j<=2;j++){
cout<<"Masukkan Angka  "<<i<<" Disamping sini  "<<j<<" : ";
                cin>>matrix[i][j];
                }
cout<<endl;
           }
           for(i=0;i<=1;i++){
           for(j=0;j<=2;j++){
                      cout<<matrix[i][j]<<" ";
                                               }
                       cout<<endl;
                             }
                       cout<<"************ \n ";
 int mat[2][2];
    for(i=0;i<=1;i++){
                      for(j=0;j<=2;j++){
cout<<"Masukkan Angka "<<i<<" Disamping sini "<<j<<" : ";
                cin>>mat[i][j];
                }
cout<<endl;
           }          
           for(i=0;i<=1;i++){
           for(j=0;j<=1;j++){
                      cout<<mat[i][j]<<" ";
                                               }
                             cout<<endl;
                             }
cout<<"*********************"<<endl;
int jumlah[i][j];{
    for(i=0;i<=1;i++){
                      cout<<endl;
           for(j=0;j<=2;j++){
jumlah[i][j]=matrix[i][j] + mat [i][j];
    cout<<"  "<<jumlah[i][j];
   
}
}
}
    system("PAUSE");
    return EXIT_SUCCESS;
}

Dasar-dasar Pemrograman : Function Faktorial

#include <cstdlib>
#include <iostream>

using namespace std;

int factorial(int f){
int hasil=1;

for(int i=1; i<=f; i++){
hasil*=i;
}
return hasil;
}

int main(int argc, char *argv[]){
int x;

cout<<”Masukan bilangan yang akan di factorial : “;
cin>>x;
cout<<x<<”! = “<<factorial(x)<<endl;
system(“PAUSE”);
return EXIT_SUCCESS;