Guest User

Untitled

a guest
Dec 7th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<cstdlib>
  2. #include<time.h>
  3. #include<iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. srand(time(0));
  9. int matriz[4][4];
  10. for(int i=0; i<4; i++)
  11. {
  12. for(int j=0; j<4; j++)
  13. {
  14. matriz[i][j] = (rand() % 15)+1;
  15. //Llenado de matriz con numeros aleatorios entre 1 y 15
  16. }
  17. }
  18. cout<<"La matriz generada es: "<<endl;
  19. for(int i=0; i <4; i++)
  20. {
  21. for(int j=0; j<4; j++)
  22. {
  23. cout<<matriz[i][j]<<"\t";
  24. //Mostramos la matriz
  25. }
  26. cout<<endl;
  27. }
  28. cout<<"\n La matriz generada como un vector es la siguiente: "<<endl;
  29. for(int i=0; i <4; i++)
  30. {
  31. for(int j=0; j<4; j++)
  32. {
  33. cout<<matriz[i][j]<<" ";
  34. //Mostramos la matriz como un vector
  35. }
  36. }
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment