Announcement

Collapse
No announcement yet.

Il pc che indovina un numero tra 0 e 1000 - Voi lo pensate soltanto

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Il pc che indovina un numero tra 0 e 1000 - Voi lo pensate soltanto

    PHP Code:
    #include <st***.h>
    #include <stdlib.h>



    int main (void){
        
        
    int scelta;
        
    int sugg;
        
    int i=0;
        
    int min 0;
        
    int max 1000;
        
    int calc;
        
        
    printf("Pensa un numero tra 0 e 1000\n");
        
    srand(time(NULL));
        
    sceltarand()%1000;
        
    i++;
        
    printf("E' per caso %d ?\n",scelta);
        
    printf("1 se più piccolo\n");
        
    printf("2 se ho fatto centro\n");
        
    printf("3 se più grande\n");
        
    scanf("%d",&sugg);
        for (;
    sugg != 2;){
            if (
    sugg==1){
                
    max=scelta;
                
    srand(time(NULL));
                
    calc=(scelta-2)-min;
                if (
    calc == 0){
                    
    calc=1;
                }
                
    scelta= (rand()%calc)+min+1;
                
    printf("E' per caso %d ?\n",scelta);
                
    scanf("%d",&sugg);
                
    i++;
            }else{
                
    min=scelta;
                
    srand(time(NULL));
                
    calc=(max-2)-scelta;
                if (
    calc == 0){
                    
    calc=1;
                }
                
    scelta= (rand()% calc)+scelta+1;
                
    printf("E' per caso %d ?\n",scelta);
                
    scanf("%d",&sugg);
                
    i++;
            }
            
        }
        
    printf ("Aleee! Ho impiegato %d tentativi\n",i);
        return 
    0;

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia