Advertisement
Gilgamesh858

Programma_Intervallo

Oct 31st, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstdio>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. #ifdef _WIN32
  9. #define PAUSE (system("PAUSE"))
  10. #else
  11. #define PAUSE (getchar())
  12. #endif
  13.  
  14. int main ()
  15. {
  16.     //Lo scopo di questo Programma è di scegliere un numero casuale tra 3-5 e 24-35.
  17.    
  18.     int numero_random1, numero_random2;
  19.    
  20.     int numero_finale[30];
  21.    
  22.     srand((unsigned int)time(0));
  23.    
  24.     for( int i=0; i < 30; i+=2)
  25.     {
  26.         numero_random1 = rand() % 3 + 3;
  27.        
  28.         numero_random2 = rand() % 12 + 24;
  29.        
  30.         numero_finale[i] = numero_random1;
  31.         numero_finale[i+1] = numero_random2;
  32.        
  33.         cout<<numero_random1<<" - "<<numero_random2<<" || array -> "<<numero_finale[i]<<" - "<<numero_finale[i+1]<<endl<<endl;
  34.     }
  35.    
  36.     //cout<< numero_random1<<endl<<numero_random2;
  37.    
  38.     cout<<" Il numero Random Generato alla fine è -> "<< numero_finale[rand() % 30];
  39.    
  40.     return EXIT_SUCCESS;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement