Minggu, 17 April 2016

PPT

PPT

No 2.
Algoritma

Fungsi std(input x : array [1..10] of integer, n : integer, rata : real) : real
{Diberikan n data kemudian dicari rata-ratanya}
Deklarasi
i, jumlah : integer
Deskripsi
jumlah = 0
for i = 1 to n do
jumlah = jumlah + sqr(x[i]-rata)
endfor
std = sqrt(jumlah/(n-1))

ket: x[i] di pakai kembali

Dev c++

source code :

#include <iostream>
#include <cmath>
using namespace std;
void calculateMean(double, double);
void calculateStandardDeviation(double, double, double);
void getLetterGrade();
int main()
{
double count;
double score, totalScores = 0.0, mean = 0.0;
cout << "How many scores do you wish to enter? ";
cin >> count;
for (double num = 1.0; num <= count; num++)
{
cout << "Enter score " << num << ": ";
cin >> score;
totalScores = totalScores + score;
}
calculateMean(count, totalScores);
calculateStandardDeviation(count, mean, totalScores);
getLetterGrade();
return 0;
}
void calculateMean(double numberScores, double totalScores)
{
double mean;
mean = (1.0 / numberScores) * totalScores;
cout << "The mean of the scores is " << mean << endl;
}
void calculateStandardDeviation(double mean, double count, double totalScores)
{
double standardDeviation;
standardDeviation = sqrt (((pow(totalScores, 2.0)) - ((1.0/count) * (pow(totalScores,2.0)))) / (count - 1.0));
cout << "The standard deviation of the scores is " << standardDeviation << endl;
}
void getLetterGrade()
{

}

outputnya :

Raptor


No 5.
Algoritma

procedure maksimum(data : larik; n : integer;output maks, item : integer)
{ procedure ini hasil modifikasi dari algoritma (…) karena selain nilai maks
dari larik data, juga perlu diketahui besar datanya item }
Deklarasi
i : integer
Deskripsi
     maks = data[1]
     item = 1
     for i = 2 to n do    
          if (data[i] > maks) then
               maks = data[i];
               item = i;
          endif          
     Endfor
procedure frekuensi(data : larik; n : integer; output f : larik)
{ data akan diambil nilai frekuensi f-nya }
Deklarasi
i : integer
Deklarasi
     for i = 1 to n do
     f[data[i]] := f[data[i]] + 1     { dengan prinsip memasukkan
               bola ke keranjang yang sesuai dengan nomornya }
  endfor

Dev C++

source code :

#include <iostream>
#include<conio.h> 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int x;
void findmod(float bil[], int n, float mod[])
{
int total[100];
int k=1;
x=0;
//untuk mengurutkan secara ascending
for(int c=0;c<n;c++)
{
for(int i=(n-1);i>=0;i--)
{
if(bil[i]<bil[i-1])
{
int temp;
temp=bil[i];
bil[i]=bil[i-1];
bil[i-1]=temp;
}
}
}
//menghitung berapa kali muncul tiap angka
for(int c=0;c<n;c++)
{
total[c]=0;
for(int i=0;i<n;i++)
{
if(bil[c]==bil[i])
{
total[c]++;
}
}
}
//menentukan nilai yang paling sering muncul
for(int c=0;c<n;c++)
{
if(total[c]>k)
{
k=total[c];
}
}
//jika modus lebih dari satu
for(int c=0;c<n;c++)
{
if(x==0)
mod[x]=0;
else
mod[x]=mod[x-1];
if(total[c]==k)
{
if(bil[c]!=mod[x])
{
mod[x]=bil[c];
x++;
}
}
}

//Jika Semua angka muncul sama banyak
int z=0;
for(int c=0;c<n;c++)
{
if(total[c]==k)
{
z++;
}
}
if(z==n)
{
x=0;
}
}
int main(int argc, char** argv) 
{
int n;
float bil[100];
float mod[100];
cout<<"Banyak N : ";cin>>n;
for(int c=0;c<n;c++)
cout<<"Nilai "<<(c+1)<<" : ";cin>>bil[c];
}
cout<<endl;
findmod(bil,n,mod);
if (x==0)
cout<<"Tidak Ada Modus!"<<endl;
else
{
cout<<"Modus : ";
for(int c=0;c<x;c++)
{
cout<<mod[c]<<" ";
}
}
getch();
}

outputnya :


Raptor



Untuk PPT silahkan kunjungi link dibawah ini :
no 1 dan 6 : Agus Prasetyo
no 3 dan 4 :Ela Dwi Anggraini

Tidak ada komentar:

Posting Komentar