Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,92 +0,0 @@
|
|||
with Ada.Numerics.Discrete_Random;
|
||||
with Ada.Text_IO;
|
||||
procedure Guess_Number is
|
||||
subtype Number is Integer range 1 .. 10;
|
||||
package Number_IO is new Ada.Text_IO.Integer_IO (Number);
|
||||
package Number_RNG is new Ada.Numerics.Discrete_Random (Number);
|
||||
Generator : Number_RNG.Generator;
|
||||
My_Number : Number;
|
||||
Your_Guess : Number;
|
||||
begin
|
||||
Number_RNG.Reset (Generator);
|
||||
My_Number := Number_RNG.Random (Generator);
|
||||
Ada.Text_IO.Put_Line ("Guess my number!");
|
||||
loop
|
||||
Ada.Text_IO.Put ("Your guess: ");
|
||||
Number_IO.Get (Your_Guess);
|
||||
exit when Your_Guess = My_Number;
|
||||
Ada.Text_IO.Put_Line ("Wrong, try again!");
|
||||
end loop;
|
||||
Ada.Text_IO.Put_Line ("Well guessed!");
|
||||
end Guess_Number;
|
||||
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
-- Another version ------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
|
||||
-- procedure main - begins program execution
|
||||
procedure main is
|
||||
guess : Integer := 0;
|
||||
counter : Integer := 0;
|
||||
theNumber : Integer := 0;
|
||||
|
||||
-- function generate number - creates and returns a random number between the
|
||||
-- ranges of 1 to 100
|
||||
function generateNumber return Integer is
|
||||
type randNum is new Integer range 1 .. 100;
|
||||
package Rand_Int is new Ada.Numerics.Discrete_Random(randNum);
|
||||
use Rand_Int;
|
||||
gen : Generator;
|
||||
numb : randNum;
|
||||
|
||||
begin
|
||||
Reset(gen);
|
||||
|
||||
numb := Random(gen);
|
||||
|
||||
return Integer(numb);
|
||||
end generateNumber;
|
||||
|
||||
-- procedure intro - prints text welcoming the player to the game
|
||||
procedure intro is
|
||||
begin
|
||||
Put_Line("Welcome to Guess the Number");
|
||||
Put_Line("===========================");
|
||||
New_Line;
|
||||
|
||||
Put_Line("Try to guess the number. It is in the range of 1 to 100.");
|
||||
Put_Line("Can you guess it in the least amount of tries possible?");
|
||||
New_Line;
|
||||
end intro;
|
||||
|
||||
begin
|
||||
New_Line;
|
||||
|
||||
intro;
|
||||
theNumber := generateNumber;
|
||||
|
||||
-- main game loop
|
||||
while guess /= theNumber loop
|
||||
Put("Enter a guess: ");
|
||||
guess := integer'value(Get_Line);
|
||||
|
||||
counter := counter + 1;
|
||||
|
||||
if guess > theNumber then
|
||||
Put_Line("Too high!");
|
||||
elsif guess < theNumber then
|
||||
Put_Line("Too low!");
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
New_Line;
|
||||
|
||||
Put_Line("CONGRATULATIONS! You guessed it!");
|
||||
Put_Line("It took you a total of " & integer'image(counter) & " attempts.");
|
||||
|
||||
New_Line;
|
||||
end main;
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
$irnd = Random(1, 10, 1)
|
||||
$iinput = -1
|
||||
While $input <> $irnd
|
||||
$iinput = InputBox("Choose a number", "Please chosse a Number between 1 and 10")
|
||||
WEnd
|
||||
MsgBox(0, "Success", "Well guessed!")
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Guess-The-Number.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 Random-Num PIC 99.
|
||||
01 Guess PIC 99.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
COMPUTE Random-Num = 1 + (FUNCTION RANDOM * 10)
|
||||
DISPLAY "Guess a number between 1 and 10:"
|
||||
|
||||
PERFORM FOREVER
|
||||
ACCEPT Guess
|
||||
|
||||
IF Guess = Random-Num
|
||||
DISPLAY "Well guessed!"
|
||||
EXIT PERFORM
|
||||
ELSE
|
||||
DISPLAY "That isn't it. Try again."
|
||||
END-IF
|
||||
END-PERFORM
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import extensions;
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
int randomNumber := randomGenerator.nextInt(1,10);
|
||||
console.printLine("I'm thinking of a number between 1 and 10. Can you guess it?");
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
(let ((number (1+ (random 10))))
|
||||
(while (not (= (read-number "Guess the number ") number))
|
||||
(message "Wrong, try again."))
|
||||
(message "Well guessed! %d" number))
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
include get.e
|
||||
|
||||
integer n,g
|
||||
n = rand(10)
|
||||
|
||||
puts(1,"I have thought of a number from 1 to 10.\n")
|
||||
puts(1,"Try to guess it!\n")
|
||||
|
||||
while 1 do
|
||||
g = prompt_number("Enter your guess: ",{1,10})
|
||||
if n = g then
|
||||
exit
|
||||
end if
|
||||
puts(1,"Your guess was wrong. Try again!\n")
|
||||
end while
|
||||
|
||||
puts(1,"Well done! You guessed it.")
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
Function GuessNumber($Guess)
|
||||
{
|
||||
$Number = Get-Random -min 1 -max 11
|
||||
Write-Host "What number between 1 and 10 am I thinking of?"
|
||||
Do
|
||||
{
|
||||
Write-Warning "Try again!"
|
||||
$Guess = Read-Host "What's the number?"
|
||||
}
|
||||
While ($Number -ne $Guess)
|
||||
Write-Host "Well done! You successfully guessed the number $Guess."
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
$myNumber = Read-Host "What's the number?"
|
||||
GuessNumber $myNumber
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
randomize
|
||||
MyNum=Int(rnd*10)+1
|
||||
Do
|
||||
x=x+1
|
||||
YourGuess=InputBox("Enter A number from 1 to 10")
|
||||
If not Isnumeric(YourGuess) then
|
||||
msgbox YourGuess &" is not numeric. Try again."
|
||||
ElseIf CInt(YourGuess)>10 or CInt(YourGuess)<1 then
|
||||
msgbox YourGuess &" is not between 1 and 10. Try Again."
|
||||
ElseIf CInt(YourGuess)=CInt(MyNum) then
|
||||
MsgBox "Well Guessed!"
|
||||
wscript.quit
|
||||
ElseIf Cint(YourGuess)<>CInt(Mynum) then
|
||||
MsgBox "Nope. Try again."
|
||||
end If
|
||||
|
||||
if x > 20 then
|
||||
msgbox "I take pity on you"
|
||||
wscript.quit
|
||||
end if
|
||||
loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue