23 lines
577 B
C++
23 lines
577 B
C++
//Patriche Robert Cosmin
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
int contaOccorrenze(int matrice[3][3], int val, int righe, int colonne) {
|
|
int conta = 0;
|
|
for (int i = 0; i < righe; i++) {
|
|
for (int j = 0; j < colonne; j++) {
|
|
if (matrice[i][j] == val) {
|
|
conta++;
|
|
}
|
|
}
|
|
}
|
|
return conta;
|
|
}
|
|
|
|
int main() {
|
|
int matrice[3][3] = {{1, 2, 3}, {4, 5, 1}, {6, 1, 7}};
|
|
int val = 1;
|
|
cout << "Occorrenze di " << val << ": " << contaOccorrenze(matrice, val, 3, 3) << endl;
|
|
return 0;
|
|
}
|