Bulls and cows: Difference between revisions

m
Fixed lang tags.
m (→‎{{header|J}}: fix lang tag)
m (Fixed lang tags.)
Line 73:
<br>
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}}
<lang algolalgol68>STRING digits = "123456789";
 
[4]CHAR chosen;
Line 351:
 
=={{header|C++}}==
<lang cpp>#include <iostream>
#include <iostream>
#include <string>
#include <algorithm>
Line 429 ⟶ 428:
std::cout << "Another game? ";
}
}</lang>
}
</lang>
 
=={{header|Common Lisp}}==
Line 601 ⟶ 599:
 
=={{header|Fan}}==
<lang Fan>**
**
** Bulls and cows. A game pre-dating, and similar to, Mastermind.
**
Line 651 ⟶ 648:
}
}
}</lang>
}
</lang>
 
=={{header|Forth}}==
{{works with|GNU Forth}}
<lang forth>include random.fs
include random.fs
 
create hidden 4 allot
Line 693 ⟶ 688:
: guess: ( "1234" -- )
bl parse 2dup ok? 0= if 2drop ." Bad guess! (4 unique digits, 1-9)" exit then
drop check? if cr ." You guessed it!" then ;</lang>
</lang>
init ok
guess: 1234 1 bulls, 0 cows ok
Line 993 ⟶ 987:
done;
print_endline "Congratulations you guessed correctly";
;;</lang>
</lang>
 
=={{header|Perl}}==
Line 1,161 ⟶ 1,154:
=={{header|R}}==
{{works with|R|2.8.1}}
<lang R>target <- sample(1:9,4)
target <- sample(1:9,4)
bulls <- 0
cows <- 0
Line 1,180 ⟶ 1,172:
} else {print("Malformed input!")}
}
print(paste("You won in",attempts,"attempt(s)!"))</lang>
</lang>
 
=={{header|Ruby}}==
Line 1,379 ⟶ 1,370:
 
=={{header|Vedit macro language}}==
<lang vedit>Buf_Switch(Buf_Free)
Buf_Switch(Buf_Free)
#90 = Time_Tick // seed for random number generator
#91 = 10 // random numbers in range 0 to 9
Line 1,426 ⟶ 1,416:
#93 = 0x7fffffff % 48271
#90 = (48271 * (#90 % #92) - #93 * (#90 / #92)) & 0x7fffffff
Return ((#90 & 0xffff) * #91 / 0x10000)</lang>
</lang>
 
=={{header|Visual Basic .NET}}==
Anonymous user