Advertisement
Guest User

guess the number

a guest
Nov 17th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.64 KB | None | 0 0
  1.   import std.stdio, std.random, std.conv, std.string;
  2.  
  3.   int rnd_number(){
  4.       immutable num = uniform(1, 25);
  5.       return num;
  6.   }
  7.  
  8.   int main(){
  9.       int solution = rnd_number();
  10.       int guess;
  11.      
  12.       for(int x = 0; x < 3; x++){
  13.           write(": ");
  14.           readf("%d", &guess);
  15.           if(guess == solution){
  16.               writeln("YEEEEEAAAHHHH");
  17.               return 0;
  18.           } else if(guess < solution){
  19.               writeln("more...");
  20.           } else {
  21.               writeln("too much...");
  22.           }
  23.       }
  24.      
  25.       writeln("oh no.., the number was: ", solution);
  26.       return 0;
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement