Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char** argv) {
  8.  
  9. const int NRMAX=100;
  10. const int NCMAX=100;
  11. int c,r,nc,nr;
  12. int mat[NRMAX][NCMAX];
  13. bool trovato=false;
  14.  
  15. do {
  16. cout<<"Inserire numero delle colonne (1-"<<NCMAX<<")? ";
  17. cin>>nc;
  18. cout<<"Inserire numero delle righe (1-"<<NRMAX<<")? ";
  19. cin>>nr;
  20. if (nc>NCMAX || nr>NRMAX) cout<<"\n\nValori inseriti non consentiti!!\n";
  21. } while (nc>NCMAX || nr>NRMAX);
  22.  
  23. srand(time(NULL));
  24.  
  25. for (r=0;r<nr;r++)
  26. for (c=0;c<nc;c++)
  27. mat[r][c]=(rand()%201)-100;
  28.  
  29. for(r=0;r<nr;r++){
  30. cout<<"\n";
  31. for(c=0;c<nc;c++){
  32. printf("%4d",mat[r][c]);
  33. }
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement