Menghitung Nilai Max dan Min "Array" -[Visual C++]-
Source Code Menghitung Nilai Max dan Min "Array" :
#include <iostream>
using namespace std;
int main ()
{
float A[100];
int n,i,j, max = A[0];// min = A[0];
cout<<"\t-[ Arif Syarifuddin ]-"<<endl;
cout<<"\t-[ TI111004 ]-"<<endl;
cout<<"\t-[ Politeknik TEDC Bandung ]-"<<endl;
cout<<"\t-[ **Menghitung Nilai Max dan Min Dari Array** ]-"<<endl<<endl<<endl;
cout << "Masukkan Jumlah Bilangan : ";
cin>>n;
for (i=0; i<n; i++)
{
cout << "Masukan Nilai Ke- "<< i+1 <<" : ";
cin >>A[i];
}
for (i=0; i<n; i++)
{
if ( A[i] > max )
max = A[i];
}
int min = A[0];
for (j=0; j<n; j++)
{
if ( A[j] < min )
min = A[j]; //cout << min << endl;
}
cout << "Nilai Max : " << max << endl;
cout << "Nilai Min : " << min;
return 0;
}
Tidak ada komentar:
Posting Komentar