Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. # Esercizio sulle Matrici 2 [+ Random]
  2.  
  3. ``` cpp
  4. //Riempi una matrice 7x5 con numeri pseudo - casuali da 5 a 15.
  5. #include <iostream>
  6. #include <cstdlib>
  7. #include <ctime>
  8. using namespace std;
  9. int main() {
  10. srand(time(NULL));
  11. int Matrice[7][5] = { 0 };
  12. for (int n = 0; n < 7; n++) {
  13. for (int m = 0; m < 5; m++)
  14. Matrice[n][m] = rand() % 15 + 5;
  15. }
  16. cout << "I numeri scelti casualmente sono:" << endl;
  17. for (int n = 0; n < 7; n++) {
  18. for (int m = 0; m < 5; m++)
  19. cout << Matrice[n][m] << endl;
  20. }
  21. }
  22. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement