arrays
Publicado por fernando (3 intervenciones) el 31/03/2023 22:25:49
crear una matriz 3*5y aplicar la lectura de filas y almacene solamente numeros multiplos de 3
Valora esta pregunta


0
#include <iostream>
using namespace std;
int main()
{
int matriz[3][5];
int i=0,j,num;
srand(time(NULL));
//llenar matriz
while (i < 3) {
j = 0;
while (j < 5) {
num = 1 + rand() % (41-1);
if (num % 5 == 0) {
matriz[i][j] = num;
j++;
}
else
continue;
}
i++;
}
//mostrar matriz
for (i=0; i<3; i++) {
for (j=0; j<5; j++) {
cout << matriz[i][j] << "\t";
}
cout << endl;
}
return 0;
}