Minggu, 27 Januari 2013

C++ : Program Mencari Nilai Maksimal dalam Matriks


Di Bawah ini adalah listing program untuk mencari nilai maksimal dalam matriks.

Listignya :
#include<iostream.h>
#include<conio.h>
void main()
{
                int matriks [4][4];
                int ikolom, ibaris;
                int maks = -1000;
                int i ,j;
                cout<<"Isi Data Matriks"<<endl;
                for(i=1; i<=4; i++)
                {
                                for(j=1; j<=4; j++)
                                {
                                                cout<<"Matriks ["<<i<<"]["<<j<<"] : ";
                                                cin>>matriks[i][j];
                                                {
                                                                if (matriks[i][j] > maks)
                                                                {
                                                                                maks = matriks[i][j];
                                                                                ibaris = i;
                                                                                ikolom = j;
                                                                }
                                                }
                                }
                }
                cout<<"Matriks"<<endl;
                for(i=1; i<=4; i++)
                {
                                for(j=1; j<=4; j++)
                                {
                                                cout<<matriks[i][j]<<" ";
                                }
                                cout<<endl;
                }
                cout<<"Nilai Maksimal : "<<maks<<endl;
                cout<<"Baris ke ["<<ibaris<<"] Kolom ke ["<<ikolom<<"]"<<endl;
                cout<<endl;
                getch();
}

Outputnya :


Artikel Terkait :

Bagikan :

0 komentar:

Posting Komentar