Selasa, 17 Mei 2011

Matrix search programs and relations


Program to read a member of two sets m and n then processed m x n, as we all know that:
1.     1.    Matrix
Is a scalar matrix is a composition of elements in the form of rows and columns.
A matrix size of m rows and n columns (m ´ n) is:
                             
            Symmetry matrix is the matrix that aij = aji for all i and j.
            Below is an example of matrix symmetry.
                                       
           Matrix of zero-one (0 / 1) is a matrix which each element is 0 or 1 only.
2.   Relation
Binary relation R between sets A and B is a subset of A ´ B
Notation: R Í (A ´ B).

Algoritmah:
Algorithm to find the value of the matrix and the relation of input.
{algorithm search, enter the input, process, search results (output)}


Declaration:
                    i, j [50]: integer
                   a, b, c, d: integer

Description:
                    for (a = 0; a <c;a++) cin>> i [a];

                  
  for (b = 0; b <d;b++) cin>> j [b];

                     
        court <<i [a ]<<","<< j [b] <<endl;

                 
     endfor

#include<iostream>
#include<conio.h>
int main ()
{
int i[50], j[50];
int a,b,c,d;
cout<<"masukkan data="; cin>>c;
for (a=0;a<c;a++)
{
cin>>i[a];}
cout<<"masukkan data=";cin>>d;
for (b=0;b<d;b++)
{
cin>>j[b];}
for (a=0;a<c;a++)
{
for (b=0;b<d;b++)
{
cout<<i[a]<<","<< j[b]<<endl;}
}
return 0;
}

Program menjumlah dan mengurang 2 bilangan integer

An array is a structured data type contained in the memory consisting of a number of elements (a) which has the same data type, variable type, number of components common tetap.Bentuk declaring:

nama_array [jumlah_eleman];

This program is a program for addition and subtraction of two integer values, where there are two input data (i, j) consisting of some value, then processed with a formula for (i = 0; i <m; i + +) {
     court <<"number to [" <<i +1 <<"] =";
then amount = bil1 + bil2 for the addition and to a reduction of less = bil1-bil2.

Algoritm:
Algorithms look for addition and subtraction of two integer values.
{search algorithms, enter inputan numbers, search process, algorithm output}
Deklarasi:
                N,bil1,bil2,jum,kur [100]: integer
Deskripsi:
                for (i=0;i<m;i++){
                    cout<<"angka ke [ "<<i+1<<"] = "
 jumlah[i]= bil1[i] + bil2[i]
jumlah[i]=bil[i]-bil[i]
                endfor;
Output:
                result of addition and subtraction


#include <cstdlib>
#include <iostream>
using namespace std;

void masukkan(int[100], int);
void penjumlahan(const int[100], const int[100], int, int[100]);
void pengurangan(const int[100], const int[100], int, int[100]);
void cetak_bigInteger(const int A[100], int);
int main(int argc, char *argv[])
{
    int n;
    int bil1[100], bil2[100];
    int jumlah[100];
    int kurang[100];

    cout<<"Masukkan bilangan : \n";
    cin>>n;
    cout<<"Bilangan pertama : \n";
    masukkan(bil1, n);
    cetak_bigInteger (bil1, n);
    cout<< "\nBilangan kedua : \n" <<endl;
    masukkan(bil2, n);
    cetak_bigInteger (bil2, n);
    penjumlahan (bil1, bil2, n, jumlah);
    cout<<" \n Hasil penjumlahan : \n";
    cetak_bigInteger (jumlah, n);
    pengurangan (bil1, bil2, n, kurang);
    cout<<" \nHasil pengurangan : \n";
    cetak_bigInteger (kurang, n);
    system("PAUSE");
    return EXIT_SUCCESS;
}
void masukkan(int B[100], int m){
     int i;
     for (i=0;i<m;i++){
     cout<<"angka ke [ "<<i+1<<"] = ";
     cin>>B[i];
             }
     }
void penjumlahan(const int bil1[100], const int bil2[100], int m, int jumlah[100]){
     int i;
     for(i=0; i<m; i++)
      jumlah[i]= bil1[i] + bil2[i];
      }
void pengurangan(const int bil1[100], const int bil2[100], int m, int kurang[100]){
     int i;
     for(i=0; i<m; i++)
      kurang[i]= bil1[i] - bil2[i];
      }
void cetak_bigInteger(const int A[100], int m){
     int i;
     for(i=0; i<m; i++){
     cout<<"       " << A[i];
     }
     }