65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <ctime>
|
|
#include <cstdlib>
|
|
#include <iomanip>
|
|
#define MAX 100
|
|
#define MIN 1
|
|
using namespace std;
|
|
|
|
void riempiMatrice(int matrice[][3], size_t RIGHE, size_t COLONNE){
|
|
for(size_t i = 0; i < RIGHE; i++)
|
|
{
|
|
for(size_t j = 0; j < RIGHE; j++)
|
|
{
|
|
matrice[i][j]=rand()%(MAX-MIN+1)+MIN;
|
|
cout << setw(6) << matrice[i][j];
|
|
}
|
|
cout << endl;
|
|
}
|
|
cout << endl << endl << endl;
|
|
}
|
|
|
|
int numeroMatrice(int matrice[][3], size_t RIGHE, size_t COLONNE){
|
|
int conteggio = 0;
|
|
for(size_t k = 0; k < RIGHE; k++)
|
|
{
|
|
for(size_t l = 0; l < COLONNE; l++)
|
|
{
|
|
if(matrice[k][l] == 13)
|
|
conteggio++;
|
|
}
|
|
}
|
|
return conteggio;
|
|
}
|
|
|
|
int multipliMatrice(int matrice[][3], size_t RIGHE, size_t COLONNE){
|
|
int conteggio = 0;
|
|
for(size_t k = 0; k < RIGHE; k++)
|
|
{
|
|
for(size_t l = 0; l < COLONNE; l++)
|
|
{
|
|
if(matrice[k][l]%17 == 0)
|
|
conteggio++;
|
|
}
|
|
}
|
|
return conteggio;
|
|
}
|
|
|
|
int main(void){
|
|
srand(time(NULL));
|
|
int matrice[3][3];
|
|
const int RIGHE = 3;
|
|
const int COLONNE = 3;
|
|
int valore;
|
|
|
|
riempiMatrice(matrice, RIGHE, COLONNE);
|
|
|
|
cout << endl << endl;
|
|
|
|
cout << numeroMatrice(matrice, RIGHE, COLONNE) << endl;
|
|
cout << multipliMatrice(matrice, RIGHE, COLONNE) << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
} |