Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. void stampaVettore(int* puntatore, int dimensione) {
  7.     for(int i = 0; i < dimensione; i++) {
  8.         cout << *puntatore << endl;
  9.         puntatore++;
  10.     }
  11. }
  12.  
  13. int* riempiVettoreCasualmente(int* puntatore, int dimensione) {
  14.     int* temp = puntatore;
  15.  
  16.     for(int i = 0; i < dimensione; i++) {
  17.         *temp = rand() % 25;
  18.         temp++;
  19.     }
  20.  
  21.     return puntatore;
  22. }
  23.  
  24. int main() {
  25.     srand(time(NULL));
  26.     const int DIMENSIONE = 10;
  27.     int vettore[DIMENSIONE] = {0};
  28.     int* puntatore = riempiVettoreCasualmente(vettore, DIMENSIONE);
  29.     stampaVettore(puntatore, DIMENSIONE);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement