Created
November 26, 2019 20:35
-
-
Save ivan-avalos/98645a8a3a08636a0233d5017cdde4fc to your computer and use it in GitHub Desktop.
Este programa imprime una matriz aleatoria.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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