Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 21 Se considera o matrice patratica. Sa se calculeze elementul minim din matrice folosind un subprogram
- de tip functie care primeste ca parametru matricea.
- */
- #include <iostream>
- using namespace std;
- void citireMatrice(int a[100][100], int &n)
- {
- cin >> n;
- for(int i = 1; i <= n; i++)
- for(int j = 1; j <= n; j++)
- cin >> a[i][j];
- }
- void afisareMatrice(int a[100][100], int n)
- {
- cout << endl;
- for(int i = 1; i <= n; i++) {
- for(int j = 1; j <= n; j++)
- cout << a[i][j] << " ";
- cout << endl;
- }
- }
- int minMatrice(int a[100][100], int n)
- {
- int min = INT_MAX;
- for(int i = 1; i <= n; i++)
- {
- for(int j = 1; j <= n; j++)
- if(a[i][j] < min)
- min = a[i][j];
- }
- return min;
- }
- int main()
- {
- int a[100][100], n;
- citireMatrice(a, n);
- afisareMatrice(a, n);
- cout << endl << "Elementul minim din matrice este: " << minMatrice(a, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment