Selasa, 17 April 2012

Algoritma Lingkaran

Deklarasi :
Konstanta
              phi = 3,14
              r : integer         {input}
              keliling,luas : real  {output}

Deskripsi :
              read(r)
              keliling = 2*phi*r
              luas = phi*r*r
              write(keliling,luas)


Flowchart

Algoritma Menghitung Konversi Suhu

{Masukan integer derajat Celcius (C),
menghitung ekivalensinya dalam derajat Reamur (R), Fahrenheit (F), dan Kelvin(K).kemudian menampilkan hasilnya di layar}

Deklarasi:
C  : real   : {derajat Celcius, input}
R  : real  : {derajat Reamur, output}
F  : real  : {derajat Fahrenheit, output}
K  : real  : {derajat Kelvin, output}

Deskripsi:
read (C)
R = 4/5*C
F = 9/5*C+32
K = C+273
write (R,F,K)


Flowchart
 

Algoritma Mencari n Faktorial

Deklarasi :
i,n : integer
faktorial : longint

Deskripsi :
read(n)
faktorial =1
for i=1 to n do
faktorial=faktorial*i
endfor
write(faktorial)



Flowchart



programnya

#include <iostream.h>
#include <conio.h>
class Operator{
friend ostream& operator<<(ostream&, Operator&);
friend istream& operator>>(istream&, Operator&);
public :
long faktorial();
private:
int n;
long hasil;
};
long Operator::faktorial(){
long fak=1;
for(int=1; i<=n; i++)
fak=fak*i;
return fak;
}
ostream& operator<<(ostream& out, Operator){
a.hasil=a.faktorial();
out<<"Hasil cara iterasi :"<<a.n<<"! adalah "<<a.hasil;
return out;
}
istream& operator>>(istream& in, Operator){
cou<<"Masukkan integer n :";
in>>a.n;
return in;
}
void main(){
Operator run;
cin>>run;
cout<<run;
getch();
}
system ("PAUSE");
return EXIT_SUCCESS;
}

Algoritma Mencari Jumlah Deret

Deklarasi :
n,jumlah,x : integer
rata : real

Deskripsi :
jumlah=0
i=1
repeat
julmah=jumlah+(1/i)
i=1+1
selisih=(1/i)-(1/(i-1))
until about(selisih)<0,001
write(jumlah,i)


Flowchart



Programnya


#include <iostream.h>
#include <conio.h>
#include <math.h>

class Deret{
 friend ostream& operator<<(ostream&, Deret&);
 public :
         float hitung_Deret();
 private:
         int n;
         float hasil;
 };

float Deret:: hitung_Deret(){
 float selisih,jumlah=0.0;
 int i=1;
 do{
 jumlah+=1.0/(i-1)-1.0/i;
 }while(selisih>=0.001);
 cout<<"Perulangan dilakukan sebanyak :"<<i<<endl;
 return jumlah;
 }

ostream& operator<<(ostream& out, Deret&){
 out<<"Jumlah deret ="<<A.hitung_Deret();
 return out;
 }

void main(){
 Deret X;
 cout<<X;
 }
system ("PAUSE");
return EXIT_SUCCESS;
}

akar imajiner

read (a,b,c)
disk = b*b-4*a*c
if (a=0) then write (‘bukan persamaan kuadrat’)
else if disk > 0 then
x1 (-b +sqrt(disk)/2*a
x2 (-b -sqrt(disk)/2*a
else if disk=0 then
x1 (-b/2*a)
x2 (x1)
else write (‘akar imajiner’)
end if
write (x1,x2)

Flowchart

menentukan nilai maksimum dan minimum dari n bilangan [array]

procedure maks_min(input data :larik; n:integer; output m1,m2:integer)
Deklarasi
i:integer

Deskripsi
m1 <-data[1]
m2 <-data[1]
for i <- 2 to n do
if (data[i]>m1) then m1 <- data[i];
if (data[i]<m2) then m2 <- data[i];
endfor

Flowchart

menentukan nilai maksimum dari n bilangan dgn [array]

function maksimum(input data :array [1..10] of integer, n:integer): integer
Deklarasi
i,temp: integer

Deskrips
temp <- data[1]
for i<- 2 to n do
temp <- maksimum2(temp, data[i])
maksimum <- temp

Flowchart


nilai deviasi standar dari n buah data

Deklarasi
i,jumlah:integer

Deskripsi
jumlah <- 0
for i <- 1 to n do
jumlah <- jumlah + sqrt(x[i]-rata)
endfor
std<- sqrt(jumlah/(n-1))

Flowchart


rata-rata dari n bilangan bulat dengan menggunakan array

Deklarasi

 i, jumlah: integer
Deskripsi
jumlah <-0
for i <- 1 to n do
jumlah<-jumlah +x[i]
endfor
rata<-jumlah/n

Flowchart

fungsi penjumlahan

flowchart

fungsi faktorial secara rekursif untuk mencari n

flowchart




   

fungsi perkalian 2 bilangan bulat dengan menggunakan operator penjumlahan

Flowchart

 

fungsi yang menentukan nilai terbesar dari 2 bilangan bulat

flowchart








programnya

#include <iostream>
#include <string>

using namespace std;
int main()
{
   string raptor_prompt_variable_zzyz;
   int a;
   int b;

   raptor_prompt_variable_zzyz ="masukan nilai a";
   cout << raptor_prompt_variable_zzyz << endl;
   cin >> a;
   raptor_prompt_variable_zzyz ="masukan nilai b";
   cout << raptor_prompt_variable_zzyz << endl;
   cin >> b;
   if (a>b)
   {
      cout << "nilai terbesar adalah "<<a << endl;   }
   else
   {
      cout << "nilai terbesar adalah "<<b << endl;   }

   system ("pause");
   return 0;
}

Minggu, 15 April 2012

Refleksi Alpro pertemuan ke-6

in reflection of this meeting to six times its news late really. but not a problem, always post ..

ok we start ..
this meeting really exciting. we first discuss the matter Alpro. understood less as usual. and there is a different, usually empty my notes. but with a written explanation from the lecturer's first record Alpro begins .. Hhahahaa ....
explanation of the cases into five exercises in the meeting.

complete explanation of the faculty, we began to excitement in the classroom.
the professor asked nine people to come forward. one of which was chosen as chairman of the team .. our next task was given ..

this task:
foreman was given a sentence (about 10 words). Each time getting a word (of course in a whisper) the head of the team would deliver the message to his friend by not mentioning the word ONE (or LAST to give up that matter). The second person will pass the word to NOT mention the word (or both LAST) and so on. up to the last, will receive messages only ONE word (or complete sentences).

this task as a game. but a serious game. because of this game is a description of the recursive ..

eehhhmmm,,, eah as usual ... although exciting but still less understood. keep the spirit and fighting ..

reflection so this time ..
thank you ..

Selasa, 10 April 2012

Refleksi Alpro pertemuan ke-7


post at the start ..
this meeting to discuss about the array. but the array is what??
Array is a structured data type that can store lots of data with a same name and occupy a place in memory of successive (contiguous) and the same data type.


brief explanations. further how the application of the array in everyday life?
one discussion group that I referred to in that group to give an example. ie on the use of the refrigerator.


indexnya as follows:
A. placed in the kitchen refrigerator
2. select the type of food and beverages
3. grouping of foods and beverages
4. put the appropriate place


input: input materials or goods to the consumer
process: food and beverages classified according to its place.
output: the result of food or beverage ingredient groupings based on the space provided.
explanation:
For example in the refrigerator, the preparation of food in the fridge with a variety of criteria types. eg drinks placed on the refrigerator door. We can classify food or drink in the space provided for the material in accordance with their own kind.


Thus my post this time ..
Thank you.