Selasa, 05 Juli 2011

Penjumlahan ( inputan tambah tiga)

This is one program in the sum, but the input of kayboart be in a specified sum in the formula processing, ie by inserting a formula that input titambah with three inputs, the results or output + 3, if you want to plus three and input + 5 if you want to add with five and so adjust as the one you add or you want by mengsetting again the formula in the program.

#include <iostream.h>
class Awal {
public :
void masukan();
void proses();
void keluaran();
private:
int a;
int hasil;
};
void Awal::masukan() {
cout << "Masukkan bilangan input : ";
cin >> a;
cout<<endl<<endl;}
void Awal::proses() {
hasil = 3 + a; }
void Awal::keluaran() {
cout << "Hasil keluaran dari proses : " <<hasil;
cout<<endl<<endl;}
int main(int argc, char *argv[]){
Awal X;
X.masukan();
X.proses();
X.keluaran();
system("PAUSE");
return EXIT_SUCCESS; }


Matrik

The matrix is a set amount (variables and constants) are arranged in rows and columns of rectangular. The matrix is a way of visualizing the variable which is a collection of numbers or other variables, such as vectors. With matrix representation, the calculation can be done with more structured. Utilization for example in explaining the linear equations, coordinate transformation, and others. Matrix as well as ordinary variables can be manipulated, like multiplied, summed, subtracted, and decomposed.
The matrix A consists of 6 rows and 2 columns. Therefore, the matrix A
said berordo 6 􀁵  2. The numbers contained in
matrix called the matrix elements. In matrix A, we can
write its elements as follows.
The elements in the first row is 1 and 3.
The elements in the second row is 1 and 4
Elements in the third row is 2 and 3.
Elements in the fourth row is 2 and 4.
Elements in the fifth row is 3 and 3.
Elements in the sixth row dalah 3 and 4



#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];}
cout<<endl;
for (a=0;a<c;a++){
for (b=0;b<d;b++){
cout<<i[a]<<","<< j[b]<<endl;}
}
return 0;}

Array


#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
main(){
int i, j;
int data_nya[5][5];
clrscr();
for(i=1;i<=3;i++){
for(j=1;j<=3;j++){
cout<<"data:"<<i<<endl;
cout<<"yait: ";
cin>>data_nya[i][j];}
}
cout<<endl;
cout<<"Tugas Kelompok alpro_gethu,,,"<<endl;
cout<<"-----------------------------"<<endl<<endl;
for(i=1;i<=3;i++){
cout<<setiosflags(ios::left)<<setw(5)<<i;
for(j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(4);
cout<<data_nya[i][j];
cout<<" ";}
cout<<endl;}
cout<<"-----------------------"<<endl;
getch();}


Compute Combinations and Permutations

The combination is to combine several objects from a group without regard to order. In combination, the order is not considered. combination combinatorics in mathematics means the set of objects that are not concerned with the order. The combination of different permutations of the importance of the object sequence. R The number of combinations of a set containing n elements can be calculated without having to pay attention to the contents of the set. The magnitude is expressed by the function: Function in a lot of literature is also expressed by the notation.
Permutation (nPr) is to combine several objects from a group with respect to the order. In the permutation, the order of the sequence diperhatikan.Jika note and every object that is available can be selected or used only once then the number of permutations that exist are:
 where n is the number of objects you can choose, r is the amount that must be selected and! is the factorial symbol
For example, there is a vote in an organization. Candidates can choose any five people. Who gets the most votes will be appointed chairman of the organization. Who received the second most votes will be appointed vice chairman. And the third most votes will be the secretary. How many voting results that might happen? Using the formula above, there are 5! / (5-3)! = 60 permutations.
Pejumlahan and Multiplication Rules
Addition rule
The set S is partitioned into subsets S1, S2, ... ... ... Sm
The number of objects in S = number of objects of all subsets
Example 1: This type of IBM computer (3), Apple (2) and HP (2)
The number of choices there are 3 + 2 + 2
multiplication rule
Set A has p elements and B has q elements
The number of combinations (a, b) = p x q
(Masing2 considered different combinations)
Example 2:
Two dice (red and green) were thrown together
The number of different results: 6 x 6
When the results should not be double: 6 x 5

#include <iostream.h>                                                 
#include <stdio.h>
#include <conio.h>
long int fak (long int x);
void main(){
int n,r, Prts,pilihan,p;
char ulang;
do{
clrscr();
cout<<"      Nama: Desmala Dewi "<<endl;
cout<<"      NIM : 10018061 "<<endl;
cout<<"      Alamat: jln. Nalen UH 192/36"<<endl<<endl;
cout<<"==================================="<<endl;
cout<<"Menghitung Kombinasi & Permutasi"<<endl;
cout<<"==================================="<<endl;
cout<<"=    1. Kombinasi                 ="<<endl;
cout<<"=    2. Permutasi                 ="<<endl;
cout<<"=    3. keluar                    ="<<endl;
cout<<"==================================="<<endl;
cout<<"Mana aj boleh: ";cin>>pilihan;
 
switch (pilihan){
case 1 :
cout<<" Itung-itung Kombinasi donk(nCr)";
cout<<endl;
cout<<" Punya n : "; cin>>n;
cout<<endl;
cout<<" Punya r : "; cin>>r;
cout<<endl;
if (n>r){
Prts = fak(n)/(fak(n-r)*fak (r));
cout<<endl;
printf(" Kom-kombinasinya : %d",Prts);
cout<<endl; }
else if (n<r){
cout<<"data tak valid";}
cout<<endl ;
break;
 
case 2 :
cout<<" cari-cari Permutasi(nPr)";
cout<<endl;
cout<<" Milik n : "; cin>>n;
cout<<endl;
cout<<" Milik r : "; cin>>r;
cout<<endl;
if (n>r){
Prts = fak (n)/fak(n-r);
cout<<endl;
printf(" Permu-muttasinya adalah: %d",Prts);
cout<<endl; }
else if (n<r){
cout<<"data tak valid";}
cout<<endl ;
break;
case 3 :
cout<<"Exit�"<<endl;
break;
default:
cout<<"Menu tidak tersedia"<<endl;
break;}
cout<<"Mau balikan gx (y/n)?";cin>>ulang;
}while(ulang == 'y');}
 
getch();
long int fak (long int n){
int f;
if (n<=1){
f=1;}
else{
f=n*fak(n-1);
 }  
return (f);}








class sorting

This sorting form jeliot, can be compared in the form c + + or dev, and if during use dev c + + or difficulty in understanding it in the form of this jeliot can help you understand it,,,

import jeliot.io.*;
public class sorting {
    public static void main() {
       int a[]=new int[10];
int cur,z,temp;
 System.out.print("Masukan Data");
        z=Input.readInt();
        for(int i=0;i<z;i++)
        {
            System.out.println("Data["+ i +"]:");
            a[i]=Input.readInt();
        }
        for(int i=0;i<z;i++)
        {
            cur=i;
            for(int k=i+1;k<z;k++)
            {
                if(a[cur]>a[k])
                {cur=k;}
            }
        temp=a[i];
        a[i]=a[cur];
        a[cur]=temp;
        }
        for(int i=0;i<z;i++)
        {
            System.out.print(a[i]);
        }
        for(int i=0;i<z;i++)
        {
            cur=i;
            for(int k=i-1;k<z;k++)
            {
                if(a[cur]<a[k])
                {cur=k;}
            }
        temp=a[i];
        a[i]=a[cur];
        a[cur]=temp;
        }
        for(int i=0;i<z;i++)
        {
            System.out.println();
            System.out.print(a[i]);
        }
    }
}


Calculating the volume of balls in jeliot

This is a program to find the area of ​​a sphere in the form jeliot,,,
How it works almost the same as in dev c + + or anything, but jeliot will be easier in understanding, using a visual, so that each step in the workmanship we can see and also how eksekusinnya. And we also do not need to imagine how it works,,,

import jeliot.io.*;
public class luas {
    public static void main()
     {
     int r;
     float luas;
     System.out.print("Masukan Jari-jari");
     r = Input.readInt();
     luas = (float)3.14*r*r;
     System.out.print("Luas lingkaran :");
     System.out.print(luas);
     float volum;
     volum = (float)4/3* (float)3.14*r*r;
     System.out.print("volum bola :");
     System.out.print(volum);  
    }
}