PROGRAM UNTUK MENCARI NILAI MAKSIMAL DAN MINIMAL
12.25
By
Unknown
KASUS 6
0
komentar
ALGORITMA :
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];
DEV C++:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
int i;
int maks;
int minn;
int x;
int A[100];
A[100] = 0;
i =1;
maks =0;
minn =10000;
raptor_prompt_variable_zzyz ="Masukan X : ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> x;
while (!(i>x))
{
raptor_prompt_variable_zzyz ="Masukan Nilai : ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> A[i];
cout << "Bilangan "<<i<<" : "<<A[i]<< endl;
if (A[i]>maks)
{
maks =A[i];
}
else
{
}
if (A[i]<minn)
{
minn =A[i];
}
else
{
}
i =i+1;
}
cout << "Nilai Maksimum : "<<maks<< endl;
cout << "Nilai Minimum : "<<minn<< endl;
return 0;
}
FLOWCHART:
0 komentar: