pearos

Nascita casuale

Apr 16th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<time.h>
  4. main()
  5. {
  6.     srand( time(NULL) );  
  7.   int mese2,giorno,anno;
  8.     char mese[12][15] = {"Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"};
  9.     mese2 = rand()%12;
  10.     switch(mese2){
  11.         case 0: giorno = rand()%31; break;
  12.         case 1: giorno = rand()%28; break;
  13.         case 2: giorno = rand()%31; break;
  14.         case 3: giorno = rand()%30; break;
  15.         case 4: giorno = rand()%31; break;
  16.         case 5: giorno = rand()%30; break;
  17.         case 6: giorno = rand()%31; break;
  18.         case 7: giorno = rand()%31; break;
  19.         case 8: giorno = rand()%30; break;
  20.         case 9: giorno = rand()%31; break;
  21.         case 10: giorno = rand()%30; break;
  22.         case 11: giorno = rand()%31; break;
  23.         }
  24.     anno = 2015 - 20;
  25.     printf("Data di nascita: %d %s %s",giorno, mese[mese2], anno);
  26.     system("PAUSE");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment