Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdlib>
- #include<time.h>
- #include<iostream>
- using namespace std;
- int main()
- {
- srand(time(0));
- int matriz[4][4];
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<4; j++)
- {
- matriz[i][j] = (rand() % 15)+1;
- //Llenado de matriz con numeros aleatorios entre 1 y 15
- }
- }
- cout<<"La matriz generada es: "<<endl;
- for(int i=0; i <4; i++)
- {
- for(int j=0; j<4; j++)
- {
- cout<<matriz[i][j]<<"\t";
- //Mostramos la matriz
- }
- cout<<endl;
- }
- cout<<"\n La matriz generada como un vector es la siguiente: "<<endl;
- for(int i=0; i <4; i++)
- {
- for(int j=0; j<4; j++)
- {
- cout<<matriz[i][j]<<" ";
- //Mostramos la matriz como un vector
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment