Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- int main(int argc, char** argv) {
- const int NRMAX=100;
- const int NCMAX=100;
- int c,r,nc,nr;
- int mat[NRMAX][NCMAX];
- bool trovato=false;
- do {
- cout<<"Inserire numero delle colonne (1-"<<NCMAX<<")? ";
- cin>>nc;
- cout<<"Inserire numero delle righe (1-"<<NRMAX<<")? ";
- cin>>nr;
- if (nc>NCMAX || nr>NRMAX) cout<<"\n\nValori inseriti non consentiti!!\n";
- } while (nc>NCMAX || nr>NRMAX);
- srand(time(NULL));
- for (r=0;r<nr;r++)
- for (c=0;c<nc;c++)
- mat[r][c]=(rand()%201)-100;
- for(r=0;r<nr;r++){
- cout<<"\n";
- for(c=0;c<nc;c++){
- printf("%4d",mat[r][c]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement