Skip to content

Instantly share code, notes, and snippets.

@ivan-avalos
Created November 26, 2019 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivan-avalos/98645a8a3a08636a0233d5017cdde4fc to your computer and use it in GitHub Desktop.
Save ivan-avalos/98645a8a3a08636a0233d5017cdde4fc to your computer and use it in GitHub Desktop.
Este programa imprime una matriz aleatoria.
// Example program
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;
int main()
{
/* Inicializar RNG */
time_t t;
srand ((unsigned) time(&t));
int n;
std::cout << "Seleccione el tamaño de su matrix: ";
std::cin >> n;
vector<vector<int> > mat(n, vector<int>(n, 0));
for (auto i = 0; i < n; i++)
{
for (auto j = 0; j < n; j++)
{
mat[i][j] = (rand() % 100) + 1;
std::cout << mat[i][j] << ", ";
}
std::cout << "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment