#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <math.h>
using namespace std;
void input(int x[],int n)
{
for (int i=1;i<=n;i++)
{cout<<"Masukan Nilai "<<i<<" : ";cin>>x[i];}
}
void tinggi(int x[],int n)
{
int max,min;
max = x[1];
min = x[1];
for (int i=2;i<=n;i++)
{
if (max < x[i])
max = x[i];
if (min > x[i])
min = x[i];
}
cout<<"\nNilai tertinggi = "<<max<<"\n";
cout<<"Nilai terendah = "<<min<<"\n";
}
int main(int argc, char *argv[])
{
int p[50],N;
cout<<"Banyaknya Data : ";cin>>N;
cout<<endl;
input(p,N);
tinggi(p,N);
getch();
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Jumat, 24 Juni 2011
program nilai maksimum dan minimum
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar