menu

Rabu, 18 Mei 2016

c++ mencari data penjualan terbesar dan terkecil araay dua dimensi

#include <iostream>
using namespace std;
void baca (int mat[100][100], int baris, int kolom)
{ int i,j;
for (i=0; i<baris; i++)
for (j=0; j<kolom; j++)
{ cout << "Data [" << i+1 << "," << j+1 << "] : ";
cin >> mat[i][j];
}
}

void cetak (const int A[100][100], int baris, int kolom)
{ int i,j;
for (i=0; i<baris; i++)
{ for (j=0; j<kolom; j++)
cout << A[i][j]<<" ";
cout << endl;
}
}

void proses(const int data[100][100], int m, int n){
int max,min;

for (int i=0; i<m; i++){
for (int j=0; j<n; j++)
if(data[i][j]>max){
max=data[i][j];       
}
}
cout<<"nilai maksimum= "<<max;
cout<<endl;

for (int i=0; i<m; i++){
for (int j=0; j<n; j++)
   {
    if(data[i][j]<min)
      {
       min=data[i][j];
      }
   }
}
cout<<"nilai minimum= "<<min;   
}




main() {
int m, n;
int data[100][100];
int max,min;

cout << "Banyak baris : ";
cin >> m;
cout << "Banyak kolom : ";
cin >> n;

baca(data,m,n);
cetak(data,m,n);
proses(data,m,n);


}


download raptor

Tidak ada komentar:

Posting Komentar