99 chai bia, 99 ngôn ngữ


42

Mục tiêu là viết một chương trình "99 Chai bia" đơn giản .. có giá trị bằng ít nhất 2 ngôn ngữ riêng biệt (ví dụ: không phải Python 2 và Python 3). Nó phải là một tập tin hoàn chỉnh sẽ chạy hoặc biên dịch.

Câu trả lời thú vị nên được bình chọn, nhưng tính gọn nhẹ cũng được tính. (Tất nhiên, sự đa dạng ngôn ngữ là mục tiêu chính.)

EDIT: Tôi muốn nói rằng để có mã C bình thường làm điều tương tự với C ++ và Objective-C được tính là đạo hàm. Mã nên làm công cụ thông minh để các dòng có ý nghĩa khác nhau với các ngôn ngữ khác nhau.


8
Chết tiệt, thời gian để đánh lên khoảng trắng của tôi!
ClickRick

24
99 lỗi logic trong mã / 99 lỗi logic / Bỏ xuống, sửa lỗi xung quanh / 117 lỗi logic trong mã ...
keshlam

6
99 lỗi xâu chuỗi trong mã / 98 lỗi xâu chuỗi / 97 lỗi xâu chuỗi trong mã / gỡ xuống, vá lỗi xung quanh
Timwi

2
Điều này mang đến một ý nghĩa hoàn toàn mới cho "Viết một lần, biên dịch / chạy mọi nơi"
Simon Forsberg

2
Thật buồn cười, khi tôi lần đầu tiên đọc tiêu đề, tôi nghĩ rằng mã phải tạo ra vần điệu trong các ngôn ngữ toàn cầu (ví dụ: tiếng Anh và tiếng Pháp).
brechmos

Câu trả lời:


52

C, Perl, PHP, Python, Ruby

Cập nhật : Tôi đã kết hợp một jsfiddle giúp trực quan hóa đường dẫn thông qua mã cho từng năm ngôn ngữ: http://jsfiddle.net/wK6bD/4/embedded/result/

Một phiên bản thay thế, loại bỏ tất cả các nhận xét và nén tất cả các chuỗi, biểu thức chính quy và thay thế không đáng kể: http://jsfiddle.net/wK6bD/5/embedded/result/

Và tôi đã lưu một byte khi tôi ở đó. Hóa ra C có một dấu chấm phẩy không cần thiết;)

#/*<?php ob_clean();"
s='''*/include<stdio.h>
main($y){char*$s,$t[3],$u[3]/*';'''
def printf(a,*b):import sys;sys.stdout.write(a%b)
for y in range(99,-1,-1):
  '''
99.downto(0){|y|$y=y;"/*=;#*/;
for($y=100;$y--;){
  #/*"
  $u=(($t=$y)+99)%100;'*/
  sprintf($t,"%d",$y);sprintf($u,"%d",($y+99)%100);
  #//';#'''
  printf("%s bottle%s of beer on the wall, %s bottle%s of beer.\n%s",
    #/* -- THIS LINE ENDS WITH CR --
    y//1or'No more','s'[:y!=1],y or'no more','''s*/
    +$y>0?$t:"No more",$s=$y!=1?"s":"",$y>0?$t:"no more",$s,$y>0?
    #//'''[:y!=1],y and'''
    "Take one down and pass it around":
    #//'''[6:38]or
    "Go to the store and buy some more");
  printf(", %s bottle%s of beer on the wall.\n\n",
    #/* -- THIS LINE ENDS WITH CR --
    y//1-1and~-y%100or'no more','''s*/
    +$y!=1?$u:"no more",$y!=2?"s":"");}
    #/*?><?php "
    %w;q(*/
    }//";#'''[:y!=2])

Xin lưu ý : Tập tin này cần được lưu với các kết thúc dòng hỗn hợp . Tất cả các dòng nên được chấm dứt bằng LF(char 10 , còn gọi là unix-style), ngoại trừ hai dòng được đánh dấu -- THIS LINE ENDS WITH CR --, nên được chấm dứt bằng CR(char 13 , còn gọi là kiểu mac). Tôi khuyên bạn nên sử dụng notepad ++ hoặc trình soạn thảo văn bản khác cho phép bạn chỉnh sửa thủ công dòng kết thúc.

Đối với PHP, nó được giả định output_bufferinglà được kích hoạt. Theo tài liệu , đây là mã hóa cứng Offkhi sử dụng CLI, bất kể inicài đặt là gì, do đó, nó cần phải được bật (tái) một cách rõ ràng:

$ php -d output_buffering=4096 bottles.pl.php.py.rb.c

Điều này cho phép bộ đệm 4kb, là giá trị 'được đề xuất'. Nếu bạn đang sử dụng một trong những cái được cung cấp inithì cái này sẽ được đặt, vì vậy nó sẽ chạy như là từ bất kỳ máy chủ web nào.

Tổng kích thước tệp là 823 byte (không tính các nhận xét về kết thúc dòng), trung bình là 164,6 byte cho mỗi ngôn ngữ.

Các phiên bản đã thử nghiệm
C - gcc 4.8.1, cl 15.00
Perl - 5.16.2
PHP - 5.4.16
Python - 2.7.6, 3.3.4
Ruby - 1.8.7, 1.9.3

Đầu ra giống hệt nhau cho tất cả năm ngôn ngữ (xem bên dưới).


Perl, PHP

<?php '>#'
;for($i='no more';100>($a="$i bottle".(2^($i+=1)?'s':'').' of beer');$o="
Take one down and pass it around, $b.

".ucfirst($f="$b, $a.$o")){$b="$a on the wall";}print"$f
Go to the store and buy some more, $b.";

Tôi thích cái này vì nó ngắn, vì vậy tôi sẽ bỏ nó. Nó cũng cho thấy PHP của Perl-wanna-be là bao nhiêu;)

Sử dụng mẫu:

$ perl bottles
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

...

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

1
Yêu thích mới của tôi. Nếu tôi không ích kỷ như vậy, tôi sẽ cho bạn tiền thưởng. Tôi sẽ thay đổi Python thành Python 2, mặc dù.
MadTux

15
Kết thúc dòng hỗn hợp? Bạn là một người xấu xa, xoắn, tàn bạo . +1
KRyan

2
@primo Vâng! Tôi hoàn toàn nghĩ rằng câu trả lời của bạn xứng đáng với tiền thưởng. Nó rất phức tạp và thông minh. Điều Perl / PHP là tuyệt vời, nhưng tôi nghĩ rằng PHP muốn là Perl chứ không phải ngược lại :)
core1024

3
Tôi không đủ kinh nghiệm để chơi golf mã, nhưng tôi đã tạo một tài khoản để nói với tư cách là một nhà thiết kế giao diện, tôi thích việc triển khai trực quan của Fiddle JS đầu tiên. Ai biết bạn mã geek có thể làm cho mọi thứ vừa hoạt động trông đẹp. +1

2
Vì mã js không thực sự quan trọng, liên kết đến jsfiddle.net/wK6bD/1/embedded/result mang lại trải nghiệm tốt hơn cho người dùng
slebetman

40

C + Ruby

#define do {
#define then {
#define end }
#define def int
#define nil {
#define print(a,b) printf("%d%s", a, b)

def bottle(i)
    nil

    print(i, (i==1)?" bottle":" bottles");
end

i=0;

def main()
    nil

    i = 99;
    while(i>=1) do
        bottle(i);
        puts(" of beer on the wall, ");
        bottle(i);
        puts(" of beer.\nTake one down and pass it around,");
        if(i==1) then
            break;
        end
        bottle(i-1);
        puts(" of beer on the wall.");
        puts("");
        i-=1;
    end
    puts("no more bottles of beer on the wall.");
    puts("");
    puts("No more bottles of beer on the wall,");
    puts("no more bottles of beer.");
    puts("Go to the store and buy some more,");
    puts("99 bottles of beer on the wall.");

end

#if 0
main
#endif

Chúng thực sự khá giống nhau khi bạn bình thường hóa cú pháp! : P


7
Điều này thật tuyệt vời.
Anubian Noob

2
Điều này cũng hợp lệ C ++ tôi nghĩ.
Vortico

1
Điều này khiến tôi tự hỏi có bao nhiêu ngôn ngữ có thể được thực hiện hoàn toàn với các chỉ thị của trình biên dịch C.
primo

@Vortico: thật đáng buồn, không. Mã C ở đây khai báo các biến và đối số mà không đặt tên kiểu của chúng, đó là (hầu như) hợp pháp trong C, nhưng bất hợp pháp trong C ++.
nneonneo

40

JavaScript (SpiderMonkey / NodeJS), Perl, PHP, Ruby

EDIT: Đã thêm vàRuby

EDIT 2:

  • In một tiêu đề;
  • Đầu ra nhất quán trong tất cả các ngôn ngữ;
  • Không có cảnh báo.

Mật mã:

//#<?php
;
$i = 99;
$php = ![];
$o = 'of beer';
$ruby = 0x0 != '';
$t = $php ? '' : '//#';
$js = !$ruby && 1 + '0' == '10';
$s = 'Go to the store and buy some more, 99 bottles of beer on the wall.';
$c = 'print($t ." 99 BOTTLES OF BEER #\\\\\\\\\\n"); while($i>=0) {  $j = $i; $k = ($i-1); $b = $i!=1 ? " bottles " : " bottle "; print("\\n" .($i > 0 ? $j : "No more") .$b .$o ." on the wall, " .($i > 0 ? $j : "no more") .$b .$o .".\\n" .($i > 0 ? "Take one down and pass it around, " .($i > 1 ? $k : "no more") ." bottle" .($i != 2 ? "s " : " ") .$o ." on the wall." : $s) ."\\n"); $i-=1; }';
$c = $js ? $c.replace('."\\n"','').replace(RegExp(' [.]','g'),'+').replace(RegExp('print','g'), typeof(console) != 'undefined' ? 'console.log' : 'print') : $c;
$c = $ruby ? $c.gsub('{',"do\n").gsub('}',"\nend").gsub(' .',' << ').gsub('$i;','$i.to_s;').gsub('1)','1).to_s') : $c;
eval($c);

Đầu ra:

D:\>node polyglot
//# 99 BOTTLES OF BEER #\\

99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
* * *
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

2
Yêu thích của tôi cho đến bây giờ :) Nó trông rất thông minh, mặc dù tôi không nói được bất kỳ ngôn ngữ nào.
MadTux

Tại sao spidermoneky chấp nhận điều đó như JS: O
David Mulder

4
@DavidMulder Bởi vì dòng ngay phía trên vòng lặp for biến nó thành JS hợp lệ! Tất cả trở thành + 's. Ôi trời.
doppelgreener

1
Nếu bạn sử dụng thông số HQ9 + chỉ bao gồm chữ viết hoa (vì vậy <?phpHello World không xuất ra), bạn có thể thêm một ngôn ngữ khác bằng cách chỉ sử dụng 9một lần

@professorfish Đủ dễ dàng:$i = 9*11;
primo

15

C ++ và PHP

Tôi nghĩ tôi sẽ cho nó đi.

EDIT: Nén nó một chút.

//99 BOTTLES OF BEER\\<br/><br/><?PHP function cat($a,$b){return $a.$b; }/*
#include<iostream>
#include<string>
#define echo(a) std::cout << a
#define cat(a,b) a<<b
int $bottles;
std::string $endline = "\n";
std::string $bottlesname;
int isset(std::string){ echo("//99 BOTTLES OF BEER\\\\\n\n"); return true; }
int main()
/**/
{
if(!isset($endline))
    $endline = "<br/>";
$bottles = 99;
$bottlesname = " bottles";
while( $bottles > 0 ){
    echo(cat(cat($bottles, $bottlesname ), " of beer on the wall, "));
    echo(cat(cat(cat(cat($bottles, $bottlesname ), " of beer."), $endline), "Take one down and pass it around, "));

    $bottlesname = --$bottles==1?" bottle":" bottles";
    if( $bottles == 0 )
        echo("no more");
    else
        echo($bottles);
    echo(cat(cat(cat($bottlesname," of beer on the wall."),$endline),$endline));
}
echo(cat("No more bottles of beer on the wall, no more bottles of beer.",$endline));
echo(cat(cat("Go to the store and buy some more, 99 bottles of beer on the wall.",$endline),$endline));;
}

Điều này sẽ biên dịch tốt như C ++ và nó sẽ tạo ra một số HTML đẹp nếu chạy qua PHP. Dù bằng cách nào, đầu ra là:

//99 BOTTLES OF BEER\\

99 bottles of beer on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down, pass it around, 97 bottles of beer on the wall.

...

3 bottles of beer on the wall, 3 bottles of beer.
Take one down, pass it around, 2 bottles of beer on the wall.

2 bottles of beer on the wall, 2 bottles of beer.
Take one down, pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

14

Haskell, PHP

Kết hợp một chức năng và một ngôn ngữ bắt buộc!

{-0;}
function cast($x){ return $x; }
function bottle($n){
/*-}
import Prelude hiding ((.)){-*///-};(*/) = ($){-
/*-}
(.) = (++)
cast f = show $ f id
f :: Int -> [String]
f n = id */ return (cast($n) . " bottles of beer on the wall, " . cast($n) . "  bottles of beer.\nTake one down and pass it around, " . cast($n-1) . " bottles of beer on the wall.\n\n");
{-0;}};echo"<pre>";for($x=99;$x>1;$x-=1)echo bottle($x);echo/*-}
main = (\x->putStr$(concat$[99,98..2]>>=f)++x)*/"1 bottle of beer on the wall, 1 bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.\n\nNo more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n";

Trong Haskell, tôi đã định nghĩa hàm */làm việc với các bình luận PHP dễ dàng hơn nhiều!


10

Brainfuck, tiếng Anh

Nguồn cho BF: http://www.99-bottles-of-beer.net/lingu-brainfuck-1718.html

++>+>++>>+>>>++++++++++[->+>+>++++++++++<<<]>>>>++++++++++[->+++++>++++++++++>++
+++++++++>++++++++>++++++++>+++>++++>+<<<<<<<<]+>--+>+++>++++++>--+>+++++>+++>++
+++>+>+>+>+>++>+>+>++[-<]<<<<<<<[->>[>>>>>>>>[<<<<<<<[->[-]>>>>>>>>>>>.<----.>>>
.<<<--.++.+++.+<-.+<<+<<<<<<<<]+>[-<[-]>>>>>[>>>+<<<<+<+<+>>>-]<<<[->>>+<<<]>[>>
>>>>+<<<<<<-]>>>>>[[-]>.<]<<<<[>>>>>-<<<<<-]>>[<<+<+<+>>>>-]<<<<[->>>>+<<<<]>[>>
>>>>+<<<<<<-]>>>>>>.<<<<<[>>>>>-<<<<<-]>>>[-<<<+<+>>>>]<<<<[->>>>+<<<<]>-[[-]>>>
>+<<<<]<<<]+>>>>>>>>>>>>>.<<<<----.>----.+++++..-<++++++++++.-------.<<[[-]>>>.<
<<]>>>>>>.<<<----.<+.>>>>.<<<<----.+++..+>+++.+[>]+>+>[->+<<-<-<<<.<<<----.-.>>>
.<<<++++++.<++.---.>>>>.<<<+++.<----.+++++++++++..------>---->------------------
-------------->>>++.-->..>>>]>>>[->[-]<<<<<<<[<]<[-]>>[>]>>>>>]+>[-<[-]<<<<[->>[
->+<<<<-<<<.<<<----.-.>>>.<<<++++++.<++.---.>>>>.<<<+++.<----.+++++++++++..-----
->---->++++++++++++++++++++++++++++++++>>>.<.>>>>>>]<<]<[->>>>[-<<+<<<<++.-->.[<
]<<<<<<<<[->[-]<]+>[-<[-]>>>>>>>>>>>>>.<<<-----.++++++++++.------.>>>>.<<<----.-
.<.>>>>.<<<<-.>+.++++++++.---------.>>>.<<<<---.>.<+++.>>>>.<<<++.<---.>+++..>>>
.<<<<++++++++.>+.>>>.<<<<--------.>--.---.++++++.-------.<+++.++>+++++>>>>.<.[<]
<<<<<<<]+>>>>>>-<<<+>>[<<[-]<+<+>>>>-]<<<<[>-<[-]]>[->>>+<<<]>[->->+++++++++<<]>
>>>>[>]>>>>]<<<<]>>>>>>]+<<<<<<<[<]<]+<+<<<<<<+<-]>>>>>>>>>>[>]>>>>>[->[-]<]+>[-
<[-]<<<<<<<<<-------------.<<----.>>>.<<<+++++.-----.>>>.<<<+++++.<++.---.>>>>.<
<<-.+.-----.+++.<.>>>>.<<<<----.>----.<+++.>>>>.<<<<--.>+++++++.++++.>>>.<<<----
--.----.--.<+++.>>>>.<<<.++.+++.+<.+>>>>>.<.>>>>>>>>>]+<[-]+<[-]<[-]<[-]+<<<[<]<
[-]<[-]<[-]<[-]++++++++++[->+>+>++++++++++<<<]>->->-<<<<<<[-]+<[-]<+<<]

99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.

96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.

95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.

94 bottles of beer on the wall, 94 bottles of beer.
Take one down and pass it around, 93 bottles of beer on the wall.

93 bottles of beer on the wall, 93 bottles of beer.
Take one down and pass it around, 92 bottles of beer on the wall.

92 bottles of beer on the wall, 92 bottles of beer.
Take one down and pass it around, 91 bottles of beer on the wall.

91 bottles of beer on the wall, 91 bottles of beer.
Take one down and pass it around, 90 bottles of beer on the wall.

90 bottles of beer on the wall, 90 bottles of beer.
Take one down and pass it around, 89 bottles of beer on the wall.

89 bottles of beer on the wall, 89 bottles of beer.
Take one down and pass it around, 88 bottles of beer on the wall.

88 bottles of beer on the wall, 88 bottles of beer.
Take one down and pass it around, 87 bottles of beer on the wall.

87 bottles of beer on the wall, 87 bottles of beer.
Take one down and pass it around, 86 bottles of beer on the wall.

86 bottles of beer on the wall, 86 bottles of beer.
Take one down and pass it around, 85 bottles of beer on the wall.

85 bottles of beer on the wall, 85 bottles of beer.
Take one down and pass it around, 84 bottles of beer on the wall.

84 bottles of beer on the wall, 84 bottles of beer.
Take one down and pass it around, 83 bottles of beer on the wall.

83 bottles of beer on the wall, 83 bottles of beer.
Take one down and pass it around, 82 bottles of beer on the wall.

82 bottles of beer on the wall, 82 bottles of beer.
Take one down and pass it around, 81 bottles of beer on the wall.

81 bottles of beer on the wall, 81 bottles of beer.
Take one down and pass it around, 80 bottles of beer on the wall.

80 bottles of beer on the wall, 80 bottles of beer.
Take one down and pass it around, 79 bottles of beer on the wall.

79 bottles of beer on the wall, 79 bottles of beer.
Take one down and pass it around, 78 bottles of beer on the wall.

78 bottles of beer on the wall, 78 bottles of beer.
Take one down and pass it around, 77 bottles of beer on the wall.

77 bottles of beer on the wall, 77 bottles of beer.
Take one down and pass it around, 76 bottles of beer on the wall.

76 bottles of beer on the wall, 76 bottles of beer.
Take one down and pass it around, 75 bottles of beer on the wall.

75 bottles of beer on the wall, 75 bottles of beer.
Take one down and pass it around, 74 bottles of beer on the wall.

74 bottles of beer on the wall, 74 bottles of beer.
Take one down and pass it around, 73 bottles of beer on the wall.

73 bottles of beer on the wall, 73 bottles of beer.
Take one down and pass it around, 72 bottles of beer on the wall.

72 bottles of beer on the wall, 72 bottles of beer.
Take one down and pass it around, 71 bottles of beer on the wall.

71 bottles of beer on the wall, 71 bottles of beer.
Take one down and pass it around, 70 bottles of beer on the wall.

70 bottles of beer on the wall, 70 bottles of beer.
Take one down and pass it around, 69 bottles of beer on the wall.

69 bottles of beer on the wall, 69 bottles of beer.
Take one down and pass it around, 68 bottles of beer on the wall.

68 bottles of beer on the wall, 68 bottles of beer.
Take one down and pass it around, 67 bottles of beer on the wall.

67 bottles of beer on the wall, 67 bottles of beer.
Take one down and pass it around, 66 bottles of beer on the wall.

66 bottles of beer on the wall, 66 bottles of beer.
Take one down and pass it around, 65 bottles of beer on the wall.

65 bottles of beer on the wall, 65 bottles of beer.
Take one down and pass it around, 64 bottles of beer on the wall.

64 bottles of beer on the wall, 64 bottles of beer.
Take one down and pass it around, 63 bottles of beer on the wall.

63 bottles of beer on the wall, 63 bottles of beer.
Take one down and pass it around, 62 bottles of beer on the wall.

62 bottles of beer on the wall, 62 bottles of beer.
Take one down and pass it around, 61 bottles of beer on the wall.

61 bottles of beer on the wall, 61 bottles of beer.
Take one down and pass it around, 60 bottles of beer on the wall.

60 bottles of beer on the wall, 60 bottles of beer.
Take one down and pass it around, 59 bottles of beer on the wall.

59 bottles of beer on the wall, 59 bottles of beer.
Take one down and pass it around, 58 bottles of beer on the wall.

58 bottles of beer on the wall, 58 bottles of beer.
Take one down and pass it around, 57 bottles of beer on the wall.

57 bottles of beer on the wall, 57 bottles of beer.
Take one down and pass it around, 56 bottles of beer on the wall.

56 bottles of beer on the wall, 56 bottles of beer.
Take one down and pass it around, 55 bottles of beer on the wall.

55 bottles of beer on the wall, 55 bottles of beer.
Take one down and pass it around, 54 bottles of beer on the wall.

54 bottles of beer on the wall, 54 bottles of beer.
Take one down and pass it around, 53 bottles of beer on the wall.

53 bottles of beer on the wall, 53 bottles of beer.
Take one down and pass it around, 52 bottles of beer on the wall.

52 bottles of beer on the wall, 52 bottles of beer.
Take one down and pass it around, 51 bottles of beer on the wall.

51 bottles of beer on the wall, 51 bottles of beer.
Take one down and pass it around, 50 bottles of beer on the wall.

50 bottles of beer on the wall, 50 bottles of beer.
Take one down and pass it around, 49 bottles of beer on the wall.

49 bottles of beer on the wall, 49 bottles of beer.
Take one down and pass it around, 48 bottles of beer on the wall.

48 bottles of beer on the wall, 48 bottles of beer.
Take one down and pass it around, 47 bottles of beer on the wall.

47 bottles of beer on the wall, 47 bottles of beer.
Take one down and pass it around, 46 bottles of beer on the wall.

46 bottles of beer on the wall, 46 bottles of beer.
Take one down and pass it around, 45 bottles of beer on the wall.

45 bottles of beer on the wall, 45 bottles of beer.
Take one down and pass it around, 44 bottles of beer on the wall.

44 bottles of beer on the wall, 44 bottles of beer.
Take one down and pass it around, 43 bottles of beer on the wall.

43 bottles of beer on the wall, 43 bottles of beer.
Take one down and pass it around, 42 bottles of beer on the wall.

42 bottles of beer on the wall, 42 bottles of beer.
Take one down and pass it around, 41 bottles of beer on the wall.

41 bottles of beer on the wall, 41 bottles of beer.
Take one down and pass it around, 40 bottles of beer on the wall.

40 bottles of beer on the wall, 40 bottles of beer.
Take one down and pass it around, 39 bottles of beer on the wall.

39 bottles of beer on the wall, 39 bottles of beer.
Take one down and pass it around, 38 bottles of beer on the wall.

38 bottles of beer on the wall, 38 bottles of beer.
Take one down and pass it around, 37 bottles of beer on the wall.

37 bottles of beer on the wall, 37 bottles of beer.
Take one down and pass it around, 36 bottles of beer on the wall.

36 bottles of beer on the wall, 36 bottles of beer.
Take one down and pass it around, 35 bottles of beer on the wall.

35 bottles of beer on the wall, 35 bottles of beer.
Take one down and pass it around, 34 bottles of beer on the wall.

34 bottles of beer on the wall, 34 bottles of beer.
Take one down and pass it around, 33 bottles of beer on the wall.

33 bottles of beer on the wall, 33 bottles of beer.
Take one down and pass it around, 32 bottles of beer on the wall.

32 bottles of beer on the wall, 32 bottles of beer.
Take one down and pass it around, 31 bottles of beer on the wall.

31 bottles of beer on the wall, 31 bottles of beer.
Take one down and pass it around, 30 bottles of beer on the wall.

30 bottles of beer on the wall, 30 bottles of beer.
Take one down and pass it around, 29 bottles of beer on the wall.

29 bottles of beer on the wall, 29 bottles of beer.
Take one down and pass it around, 28 bottles of beer on the wall.

28 bottles of beer on the wall, 28 bottles of beer.
Take one down and pass it around, 27 bottles of beer on the wall.
27 bottles of beer on the wall, 27 bottles of beer.
Take one down and pass it around, 26 bottles of beer on the wall.

26 bottles of beer on the wall, 26 bottles of beer.
Take one down and pass it around, 25 bottles of beer on the wall.

25 bottles of beer on the wall, 25 bottles of beer.
Take one down and pass it around, 24 bottles of beer on the wall.

24 bottles of beer on the wall, 24 bottles of beer.
Take one down and pass it around, 23 bottles of beer on the wall.

23 bottles of beer on the wall, 23 bottles of beer.
Take one down and pass it around, 22 bottles of beer on the wall.

22 bottles of beer on the wall, 22 bottles of beer.
Take one down and pass it around, 21 bottles of beer on the wall.

21 bottles of beer on the wall, 21 bottles of beer.
Take one down and pass it around, 20 bottles of beer on the wall.

20 bottles of beer on the wall, 20 bottles of beer.
Take one down and pass it around, 19 bottles of beer on the wall.

19 bottles of beer on the wall, 19 bottles of beer.
Take one down and pass it around, 18 bottles of beer on the wall.

18 bottles of beer on the wall, 18 bottles of beer.
Take one down and pass it around, 17 bottles of beer on the wall.

17 bottles of beer on the wall, 17 bottles of beer.
Take one down and pass it around, 16 bottles of beer on the wall.

16 bottles of beer on the wall, 16 bottles of beer.
Take one down and pass it around, 15 bottles of beer on the wall.

15 bottles of beer on the wall, 15 bottles of beer.
Take one down and pass it around, 14 bottles of beer on the wall.

14 bottles of beer on the wall, 14 bottles of beer.
Take one down and pass it around, 13 bottles of beer on the wall.

13 bottles of beer on the wall, 13 bottles of beer.
Take one down and pass it around, 12 bottles of beer on the wall.

12 bottles of beer on the wall, 12 bottles of beer.
Take one down and pass it around, 11 bottles of beer on the wall.

11 bottles of beer on the wall, 11 bottles of beer.
Take one down and pass it around, 10 bottles of beer on the wall.

10 bottles of beer on the wall, 10 bottles of beer.
Take one down and pass it around, 9 bottles of beer on the wall.

9 bottles of beer on the wall, 9 bottles of beer.
Take one down and pass it around, 8 bottles of beer on the wall.

8 bottles of beer on the wall, 8 bottles of beer.
Take one down and pass it around, 7 bottles of beer on the wall.

7 bottles of beer on the wall, 7 bottles of beer.
Take one down and pass it around, 6 bottles of beer on the wall.

6 bottles of beer on the wall, 6 bottles of beer.
Take one down and pass it around, 5 bottles of beer on the wall.

5 bottles of beer on the wall, 5 bottles of beer.
Take one down and pass it around, 4 bottles of beer on the wall.

4 bottles of beer on the wall, 4 bottles of beer.
Take one down and pass it around, 3 bottles of beer on the wall.

3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

Nếu bạn muốn thực sự gian lận, đó cũng là PHP!
hvd

2
Các dấu chấm và dấu phẩy có gây ra vấn đề khi chạy như Brainf *** không?
stommestack

2
Chắc chắn rồi. Những điều đó ,.sẽ gây ra vấn đề. Khắc phục điều này bằng cách thêm vào [trước phần tiếng Anh và ]ở cuối.
Justin

Tôi đã thử nghiệm beefvà họ không gây ra vấn đề.
nyuszika7h

,đọc một NULLký tự ( U+0000).
dùng75200

7

PHP và (Aheui)

<?php
$b = 99;
while(true) {
    echo ($b==0 ? "No more" : $b)." bottle".($b==1 ? "" : "s")." of beer on the wall, ".($b==0 ? "no more" : $b)." bottle".($b==1 ? "" : "s")." of beer.\n";
    if($b == 0) {
        echo "Go to the store and buy some more";
        $b = 99;
    }
    else {
        echo "Take one down and pass it around";
        $b--;
    }
    echo ", ".($b==0 ? "no more" : $b)." bottle".($b==1 ? "" : "s")." of beer on the wall.\n\n";
    if($b == 99) break;
}
/*
발발따밤따박박나타삭밤밣따산박밦따밞뚜
우어어어어어어어어어어어어어어어어어어
아우
오사뺘뿌처밞밞따받타맣산빠받다맣삭빠맣산빠박박나다맣빠받다맣빠밦다맣빠밝타맣수
오우어명여어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어
오삭빠맣산빠발타발타맣빠받다맣빠밣다빠맣맣빠맣빠밝타맣수
오우어어어어어어어어어어어어어어멓더벍뻐선처우텨너벅벅뻐
오우어어어어어어어어어어어어어어어어어어어어어
오아삭빠맣산빠받다맣빠밦타맣삭빠맣산빠발타발타맣빠밝타빠맣맣빠밦다맣삭빠맣산빠받다맣빠박다뭏
오뭏뻐멓더벖더벖뻐석멓뻐멓뻐멓터벖터벌뻐멓더벖더벌뻐선멓뻐석멓터벍뻐멓터범뻐멓더벓뻐선멓뻐석
오사뺘뿌처산빠박다맣빠받다맣삭빠맣산빠박박나다맣빠받다맣빠밦다맣빠밝타맣수
오우어명여어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어
오삭빠맣산빠발타발타맣빠받다맣빠밣다빠맣맣빠맣빠밝타맣수
오우어어어어어어어어어어어어어어멓더벍뻐선처우텨너벅벅뻐
오우어어어어어어어어어어어어어어어어어어어어어
오삭빠맣산빠받다맣빠밦타맣삭빠맣산빠발타발타맣빠밝타빠맣맣빠밦다맣밦밝따밤다맣발발다뭏
오우어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어
오사뺘우차박밦따밝따맣산빠발타밦타맣빠박박나타맣빠밝타맣삭빠맣산빠받다맣빠박다맣빠밝타뮿
오ㅇㅇ아아밣밣따밝다맣산빠받다맣삭빠맣산빠밣다맣빠받다맣삭빠맣산빠밣다맣빠밤타맣빠밝타뮿
오뮿뻐석멓터벓뻐멓더벅뻐멓터벖터벌뻐선멓뻐석멓더벅뻐멓더벖더벌뻐멓더벋뻐멓터벓뻐선멓뻐석
오유멓터벓뻐멓더벅뻐멓터벖터벌뻐선멓뻐석멓터벍뻐멓더벖뻐멓더벋뻐멓더벓뻐멓더벍뻐선멓뻐석
오삭산빠밤다맣빠발타밦타맣빠밝다빠맣맣삭빠맣산빠받타맣빠밣다맣삭빠뮿
초삭빠맣산빠발타발타맣빠밞다빠맣밤다맣삭빠맣산빠밝다맣빠받다맣빠박박나다맣빠밝타뮿
희유어어어어어멓터벓뻐멓더벅뻐멓더벎뻐멓더벋뻐멓더벖뻐멓터벖터벌뻐선
툐우어어어어어어어어어어어어어어어어어멓터벍뻐멓더벖뻐멓더벅멓뻐더너벅벅뻐선멓뻐석
토삭빠밦다밦다맣빠뭏
노우터너벅벅처불뼈서
복우더터너벅벅뱔뗘따볌
복사뺘뿌처산빠박다맣빠받다맣삭빠맣산빠박박나다맣빠받다맣빠밦다맣빠밝타맣수
또우어명여어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어어
봄삭빠맣산빠발타발타맣빠받다맣빠밣다빠맣맣빠맣빠밝타맣수
또우어어어어어어어어어어어어어어멓더벍뻐선처우텨너벅벅뻐
볼우어어어어어어어어어어어어어어어어어어어어어
볼아삭빠맣산빠받다맣빠밦타맣삭빠맣산빠발타발타맣빠밝타빠맣맣빠밦다맣삭빠맣산빠받다맣빠박다뭏
뽀불벌멓더벍더벍뻐석멓뻐멓뻐멓터벖터벌뻐멓더벖더벌뻐선멓뻐석멓터벍뻐멓터범뻐멓더벓뻐선멓뻐석
소댜몋빠몋

Aheui đã được thử nghiệm với naheui .

Tôi biết đó là gian lận, nhưng dù sao nó cũng hoạt động.


6

Điều này sẽ hoạt động trong Python 3 và Julia.

[[print(b, " bottles of beer on the wall, ", b, " bottles of beer.\nTake one down and pass it around, ", b-1, " bottles of beer on the wall.\n" ) for b in l] for l in [[12 * i + j + 4 for j in [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]] for i in [7, 6, 5, 4, 3, 2, 1, 0]]]
print("3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n")
print("2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n")
print("1 bottle of beer on the wall, 1 bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.\n")
print("No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n")

5

Điều này vi phạm các quy tắc, nhưng tôi nghĩ theo một cách thú vị.

Nó được viết bằng C và C ++. Trong C ++, nó có 99 chai khá chuẩn.

Trong C, đầu tiên nó lấp đầy bức tường, sau đó làm trống nó.

#include <stdio.h>

static int bottle_count = 99;

void bottles(int n, int fill) {
  if (fill) {
    printf("%d bottles of beer on the wall, pick one up place it away,\n", n);
    bottle_count = n+1;
  } else {
    printf("%d bottles of beer on the wall, take one down pass it around,\n", n);
    bottle_count = n-1;
  }
}

void empty_wall() {
  int wall;
  int i;
  wall = bottle_count;

  int speedup;
  speedup = 0;

  for (i = 0; i < wall; ++i) {
    if (++speedup == 4)
    {
      printf("...\n");
      i = wall-3;
    }
    bottles( wall-i, 0 );
  }
  printf("no bottles of beer on the wall!");
}

struct b_98 {};
struct b_97 {};
struct b_96 {};
struct b_3 {};
struct b_2 {};
struct b_1 {};
struct b_0 {};

void do_stuff() {
  bottle_count = 99;
  b_0();
  b_1();
  b_2();
  b_3();
  if (bottle_count<99)
    printf("...\n");
  b_96();
  b_97();
  b_98();
  empty_wall();
}

void b_0() { bottles(0,1); }
void b_1() { bottles(1,1); }
void b_2() { bottles(2,1); }
void b_3() { bottles(3,1); }
void b_96() { bottles(96,1); }
void b_97() { bottles(97,1); }
void b_98() { bottles(98,1); }

int main() {
  do_stuff();
  return 0;
}

Heh. Tôi thích nó :)
MadTux

5

BrainFuck và Python 2

Điều này sẽ biên dịch và chạy theo CPython2.7 (và có thể là những người khác) cũng như một trình thông dịch BrainFuck. Đây là hai ngôn ngữ riêng biệt, có rất ít sự chồng chéo và câu trả lời này hoàn toàn gian lận.

# Thanks to Raphael Bois for the code (taken from http://goo(dot)gl/GddKtS)
# ++>+>++>>+>>>:++++++++++[->+>+>++++++++++<<<]>>>>++++++++++[->+++++>++++++++++>+++++++++++>++++++++>++++++++>+++>++++>+<<<<<<<<]+>--+>+++>++++++>--+>+++++>+++>+++++>+>+>+>+>++>+>+>++[-<]<<<<<<<[->>[>>>>>>>>[<<<<<<<[->[-]>>>>>>>>>>>.<----.>>>.<<<--.++.+++.+<-.+<<+<<<<<<<<]+>[-<[-]>>>>>[>>>+<<<<+<+<+>>>-]<<<[->>>+<<<]>[>>>>>>+<<<<<<-]>>>>>[[-]>.<]<<<<[>>>>>-<<<<<-]>>[<<+<+<+>>>>-]<<<<[->>>>+<<<<]>[>>>>>>+<<<<<<-]>>>>>>.<<<<<[>>>>>-<<<<<-]>>>[-<<<+<+>>>>]<<<<[->>>>+<<<<]>-[[-]>>>>+<<<<]<<<]+>>>>>>>>>>>>>.<<<<----.>----.+++++..-<++++++++++.-------.<<[[-]>>>.<<<]>>===>>>>.<<<----.<+.>>>>.<<<<----.+++..+>+++.+[>]+>+>[->+<<-<-<<<.<<<----.-.>>>.<<<++++++.<++.---.>>>>.<<<+++.<----.+++++++++++..------>---->-------------------------------->>>++.-->..>>>]>>>[->[-]<<<<<<<[<]<[-]>>[>]>>>>>]+>[-<[-]<<<<[->>[->+<<<<-<<<.<<<----.-.>>>.<<<++++++.<++.---.>>>>.<<<+++.<----.+++++++++++..------>---->++++++++++++++++++++++++++++++++>>>.<.>>>>>>]<<]<[->>>>[-<<+<<<<++.-->.[<]<<<<<<<<[->[-]<]+>[-<[-]>>>>>>>>>>>>>.<<<-----.++++++++++.------.>>>>.<<<----.-.<.>>>>.<<<<-.>+.++++++++.---------.>>>.<<<<---.>.<+++.>>>>.<<<++.<---.>+++..>>>.<<<<++++++++.>+.>>>.<<<<--------.>--.---.++++++.-------.<+++.++>+++++>>>>.<.[<]<<<<<<<]+>>>>>>-<<<+>>[<<[-]<+<+>>>>-]<<<<[>-<[-]]>[->>>+<<<]>[->->+++++++++<<]>>>>>[>]>>>>]<<<<]>>>>>>]+<<<<<<<[<]<]+<+<<<<<<+<-]>>>>>>>>>>[>]>>>>>[->[-]<]+>[-<[-]<<<<<<<<<-------------.<<----.>>>.<<<+++++.-----.>>>.<<<+++++.<++.---.>>>>.<<<-.+.-----.+++.<.>>>>.<<<<----.>----.<+++.>>>>.<<<<--.>+++++++.++++.>>>.<<<------.----.--.<+++.>>>>.<<<.++.+++.+<.+>>>>>.<.>>>>>>>>>]+<[-]+<[-]<[-]<[-]+<<<[<]<[-]<[-]<[-]<[-]++++++++++[->+>+>++++++++++<<<]>->->-<<<<<<[-]+<[-]<+<<]

dot = chr(46)
comma = chr(44)

for x in range(99, 2, -1):
    print """%d bottles of beer on the wall%s %d bottles of beer%s
Take one down and pass it around%s %d bottles of beer on the wall%s
""" % (x, comma, x, dot, comma, x - 1, dot)

print """2 bottles of beer on the wall%s 2 bottles of beer%s
Take one down and pass it around%s 1 bottle of beer on the wall%s

1 bottle of beer on the wall%s 1 bottle of beer%s
Take one down and pass it around%s no more bottles of beer on the wall%s

No more bottles of beer on the wall%s no more bottles of beer%s
Go to the store and buy some more%s 99 bottles of beer on the wall%s""" % (comma, dot, comma, dot, comma, dot, comma, dot, comma, dot, comma, dot)

Dòng thứ hai là mã chạy BrainFuck. Thông dịch viên BrainFuck nên bỏ qua phần còn lại của mã và thông dịch viên trực tuyến sẽ chạy nó.

Phần còn lại của mã là mã Python. Ban đầu nó chỉ là in toàn bộ lời bài hát, nhưng điều đó không vui chút nào. Điều tương tự cũng sẽ được thực hiện đối với mã BrainFuck, nhưng nó đã bị hạn chế bởi các giới hạn ký tự trong các bài đăng (khoảng 270.000 ký tự).


Tôi không nghĩ đầu ra Python là chính xác.
xem

@TheRare Bạn nói đúng, chỉ cần sửa nó (99 đã được mã hóa cứng)
Kevin Brown

5
Bạn vừa thêm mã brainfuck làm bình luận ... Thất vọng: '(
Anubian Noob

2
Đầu tiên bạn nói điều đó thật tồi tệ sau đó bạn nhận xét nó từ người khác. nghiêm túc?
bebe

@bebe Hình như tôi quên xóa cái đó, cái xấu của tôi. Điều đó đã được thêm vào cho phiên bản gốc (300k ký tự), nhưng điều đó đã bị hạn chế (như đã lưu ý trong bài đăng).
Kevin Brown

4

Lua và (F) ASM

S=10;--[[
irp x,<display 'The beer song:',13,10>,<rept 101 d:0\{reverse match,\\{j equ 'If one bottle of beer should accidently fall ...',13,10\\}match,\\{p equ 's'\\}match,\\{q equ \`d\\}match=1,d\\{p equ ''\\}match=0,d\\{q equ 'no'\\}match=0,d\\{j equ 'Who drunk all the beer!',13,10\\}match f,q\\{display q,' bottle',p,' of beer on the wall, ',q,' bottle',p,' of beer,',13,10,j\\}\}>{x}
S=10;]]--
S=10; beer=99
S=10; repeat
S=10; print(beer.." bottles of beer on the wall, "..beer.." bottles")
S=10; beer=beer-1
S=10; print("Take one down and pass it around, "..beer.." bottles of beer on the wall.")
S=10; print()
S=10; until beer==1
S=10; print("1 bottle of beer on the wall, 1 bottle of beer.")
S=10; print("Take one down and pass it around, no more bottles of beer on the wall.")
S=10; print()
S=10; print("No more bottles of beer on the wall, no more bottles of beer.")

Tín dụng cho Revolution for the Fasm one liner, mặc dù mọi thứ ở giữa dòng 1 và 3 đều bị Lua phớt lờ để tôi có thể viết một chương trình fasm dài vô tận ở đó.

Mẹo nhỏ là trong lua, bạn có thể sử dụng dấu chấm phẩy để tách hướng dẫn, để viết nhiều hướng dẫn trên cùng một dòng, trong khi trong fasm, dấu chấm phẩy là bắt đầu một nhận xét. S = 10; là một bài tập hợp lệ trong cả hai ngôn ngữ, mọi thứ khác đều khá rõ ràng


3

J, Python 2.x

Tôi đến bữa tiệc muộn một chút, nhưng ồ. Không có gì quá lạ mắt ở đây, vì đây là lần đầu tiên tôi đa thê. Python hoàn toàn không thể trộn lẫn với J; Vì vậy, về cơ bản tôi đã nhận xét J trong Python và biến Python thành một chuỗi ký tự trong J. Tôi có thể sẽ thêm nhiều ngôn ngữ sau này.

(''''"_)`(''"_)@.(1) 1
number =: 'No more'"_`('no more'"_)@.([ = 0:)`(":@])@.(] > 0:)
bottle =: number , {.&' bottles'@(8: - =&1@])
verse1 =: 1&bottle, ' of beer on the wall, '"_, bottle, ' of beer.'"_
verse2 =: 'Take one down and pass it around, '"_, bottle@<:, ' of beer on the wall.'"_
verse  =: verse1 ,: verse2
song   =: (<:@[ $: ] , verse@[ , ''"_)`(] , verse1@[)@.([ < 1:)
sing   =: (] song ''"_) , 'Go to the store and buy some more, '"_ , bottle , ' of beer on the wall.'"_
sing ". 2 {. 0 : 0
99''')
print(lambda x:x(x,99,lambda c,w=1,p=0:"%s %s of beer%s"%(c or"nN"[p]+"o more","bottle"+"s"*(c!=1)," on the wall"*w)))(lambda x,c,y:c+1and"%s, %s.\n%s"%(y(c,1,1),y(c,0),"Take one down and pass it around, %s.\n\n"%y(c-1)*(c>0))+x(x,c-1,y)or"Go to the store and buy some more, %s.\n"%y(99)
)

2

C # + Ruby

using System;

namespace bottles
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 99; i >= 0; i--)
                Console.WriteLine("{0} bottles", i);
        }
    }
}

/*
#!/usr/bin/ruby

99.downto(0){|i|
print i.to_s+" bottles\n"
}

__END__
*/

để chạy (Ruby):
ruby -x script.cs


0

Điều này sẽ hoạt động trong C, C ++ và Objective-C. Objective-C ++ chưa được thử nghiệm nhưng có thể sẽ hoạt động:

#include <stdio.h>

int main(void)
{       
        int b;

        for (b = 99; b >= 0; b--) {
                switch (b) {
                case 0:
                        printf("No more bottles of beer on the wall, no more bottles of beer.\n");
                        printf("Go to the store and buy some more, 99 bottles of beer on the wall.\n");
                        break;
                case 1:
                        printf("1 bottle of beer on the wall, 1 bottle of beer.\n");
                        printf("Take one down and pass it around, no more bottles of beer on the wall\n");
                        break;
                default:
                        printf("%d bottles of beer on the wall, %d bottles of beer.\n", b, b);      
                         printf("Take one down and pass it around, %d %s of beer on the wall.\n" ,b - 1,((b - 1) > 1)? "bottles" : "bottle");
                        break;
                }
        }       

        return 0;
}

9
is valid in at least 2 distinct languages (e.g. not Python2 and Python3)- Tôi sẽ nói điều này hoàn toàn không vượt qua yêu cầu đó. Cuộc gọi của OP mặc dù.
xem

3
@TheRare Bạn nói rằng C ++ và C không phải là hai ngôn ngữ khác nhau?

4
Python2 và Python3 không tương thích, cũng như C ++ và C. Tuy nhiên, bạn vẫn có thể viết mã tự hoạt động trên cả hai. Điều đó làm cho chúng KHÔNG khác biệt. Ví dụ, Python, Ruby và C đều khác biệt với nhau.
xem

1
@TheRare Nó chỉ xảy ra với tôi, nhưng thách thức viết mã hoạt động ở cả hai;)

7
Đây rõ ràng là mã C chỉ. Nó không sử dụng bất kỳ tính năng nào của C ++, Objective C hoặc Objective C ++ chưa được tích hợp vào C. Ba trình biên dịch khác sẽ biên dịch mã C bình thường. Vì vậy, theo như tôi có thể nói, điều này không được viết bằng C ++, ObjC hoặc ObjC ++. Chỉ đơn giản là C đủ để những trình biên dịch khác cũng sẽ biên dịch nó vì chúng tương thích ngược.
Adam Davis

0

Ruby, Golfscript

"#{File.write('out.txt', "99 bottles of beer on the wall,
99 bottles of beer.
Take one down, pass it around,
98 bottles of beer on the wall.

98 bottles of beer on the wall,
98 bottles of beer.
Take one down, pass it around,
97 bottles of beer on the wall.

97 bottles of beer on the wall,
97 bottles of beer.
Take one down, pass it around,
96 bottles of beer on the wall.

96 bottles of beer on the wall,
96 bottles of beer.
Take one down, pass it around,
95 bottles of beer on the wall.

95 bottles of beer on the wall,
95 bottles of beer.
Take one down, pass it around,
94 bottles of beer on the wall.

94 bottles of beer on the wall,
94 bottles of beer.
Take one down, pass it around,
93 bottles of beer on the wall.

93 bottles of beer on the wall,
93 bottles of beer.
Take one down, pass it around,
92 bottles of beer on the wall.

92 bottles of beer on the wall,
92 bottles of beer.
Take one down, pass it around,
91 bottles of beer on the wall.

91 bottles of beer on the wall,
91 bottles of beer.
Take one down, pass it around,
90 bottles of beer on the wall.

90 bottles of beer on the wall,
90 bottles of beer.
Take one down, pass it around,
89 bottles of beer on the wall.

89 bottles of beer on the wall,
89 bottles of beer.
Take one down, pass it around,
88 bottles of beer on the wall.

88 bottles of beer on the wall,
88 bottles of beer.
Take one down, pass it around,
87 bottles of beer on the wall.

87 bottles of beer on the wall,
87 bottles of beer.
Take one down, pass it around,
86 bottles of beer on the wall.

86 bottles of beer on the wall,
86 bottles of beer.
Take one down, pass it around,
85 bottles of beer on the wall.

85 bottles of beer on the wall,
85 bottles of beer.
Take one down, pass it around,
84 bottles of beer on the wall.

84 bottles of beer on the wall,
84 bottles of beer.
Take one down, pass it around,
83 bottles of beer on the wall.

83 bottles of beer on the wall,
83 bottles of beer.
Take one down, pass it around,
82 bottles of beer on the wall.

82 bottles of beer on the wall,
82 bottles of beer.
Take one down, pass it around,
81 bottles of beer on the wall.

81 bottles of beer on the wall,
81 bottles of beer.
Take one down, pass it around,
80 bottles of beer on the wall.

80 bottles of beer on the wall,
80 bottles of beer.
Take one down, pass it around,
79 bottles of beer on the wall.

79 bottles of beer on the wall,
79 bottles of beer.
Take one down, pass it around,
78 bottles of beer on the wall.

78 bottles of beer on the wall,
78 bottles of beer.
Take one down, pass it around,
77 bottles of beer on the wall.

77 bottles of beer on the wall,
77 bottles of beer.
Take one down, pass it around,
76 bottles of beer on the wall.

76 bottles of beer on the wall,
76 bottles of beer.
Take one down, pass it around,
75 bottles of beer on the wall.

75 bottles of beer on the wall,
75 bottles of beer.
Take one down, pass it around,
74 bottles of beer on the wall.

74 bottles of beer on the wall,
74 bottles of beer.
Take one down, pass it around,
73 bottles of beer on the wall.

73 bottles of beer on the wall,
73 bottles of beer.
Take one down, pass it around,
72 bottles of beer on the wall.

72 bottles of beer on the wall,
72 bottles of beer.
Take one down, pass it around,
71 bottles of beer on the wall.

71 bottles of beer on the wall,
71 bottles of beer.
Take one down, pass it around,
70 bottles of beer on the wall.

70 bottles of beer on the wall,
70 bottles of beer.
Take one down, pass it around,
69 bottles of beer on the wall.

69 bottles of beer on the wall,
69 bottles of beer.
Take one down, pass it around,
68 bottles of beer on the wall.

68 bottles of beer on the wall,
68 bottles of beer.
Take one down, pass it around,
67 bottles of beer on the wall.

67 bottles of beer on the wall,
67 bottles of beer.
Take one down, pass it around,
66 bottles of beer on the wall.

66 bottles of beer on the wall,
66 bottles of beer.
Take one down, pass it around,
65 bottles of beer on the wall.

65 bottles of beer on the wall,
65 bottles of beer.
Take one down, pass it around,
64 bottles of beer on the wall.

64 bottles of beer on the wall,
64 bottles of beer.
Take one down, pass it around,
63 bottles of beer on the wall.

63 bottles of beer on the wall,
63 bottles of beer.
Take one down, pass it around,
62 bottles of beer on the wall.

62 bottles of beer on the wall,
62 bottles of beer.
Take one down, pass it around,
61 bottles of beer on the wall.

61 bottles of beer on the wall,
61 bottles of beer.
Take one down, pass it around,
60 bottles of beer on the wall.

60 bottles of beer on the wall,
60 bottles of beer.
Take one down, pass it around,
59 bottles of beer on the wall.

59 bottles of beer on the wall,
59 bottles of beer.
Take one down, pass it around,
58 bottles of beer on the wall.

58 bottles of beer on the wall,
58 bottles of beer.
Take one down, pass it around,
57 bottles of beer on the wall.

57 bottles of beer on the wall,
57 bottles of beer.
Take one down, pass it around,
56 bottles of beer on the wall.

56 bottles of beer on the wall,
56 bottles of beer.
Take one down, pass it around,
55 bottles of beer on the wall.

55 bottles of beer on the wall,
55 bottles of beer.
Take one down, pass it around,
54 bottles of beer on the wall.

54 bottles of beer on the wall,
54 bottles of beer.
Take one down, pass it around,
53 bottles of beer on the wall.

53 bottles of beer on the wall,
53 bottles of beer.
Take one down, pass it around,
52 bottles of beer on the wall.

52 bottles of beer on the wall,
52 bottles of beer.
Take one down, pass it around,
51 bottles of beer on the wall.

51 bottles of beer on the wall,
51 bottles of beer.
Take one down, pass it around,
50 bottles of beer on the wall.

50 bottles of beer on the wall,
50 bottles of beer.
Take one down, pass it around,
49 bottles of beer on the wall.

49 bottles of beer on the wall,
49 bottles of beer.
Take one down, pass it around,
48 bottles of beer on the wall.

48 bottles of beer on the wall,
48 bottles of beer.
Take one down, pass it around,
47 bottles of beer on the wall.

47 bottles of beer on the wall,
47 bottles of beer.
Take one down, pass it around,
46 bottles of beer on the wall.

46 bottles of beer on the wall,
46 bottles of beer.
Take one down, pass it around,
45 bottles of beer on the wall.

45 bottles of beer on the wall,
45 bottles of beer.
Take one down, pass it around,
44 bottles of beer on the wall.

44 bottles of beer on the wall,
44 bottles of beer.
Take one down, pass it around,
43 bottles of beer on the wall.

43 bottles of beer on the wall,
43 bottles of beer.
Take one down, pass it around,
42 bottles of beer on the wall.

42 bottles of beer on the wall,
42 bottles of beer.
Take one down, pass it around,
41 bottles of beer on the wall.

41 bottles of beer on the wall,
41 bottles of beer.
Take one down, pass it around,
40 bottles of beer on the wall.

40 bottles of beer on the wall,
40 bottles of beer.
Take one down, pass it around,
39 bottles of beer on the wall.

39 bottles of beer on the wall,
39 bottles of beer.
Take one down, pass it around,
38 bottles of beer on the wall.

38 bottles of beer on the wall,
38 bottles of beer.
Take one down, pass it around,
37 bottles of beer on the wall.

37 bottles of beer on the wall,
37 bottles of beer.
Take one down, pass it around,
36 bottles of beer on the wall.

36 bottles of beer on the wall,
36 bottles of beer.
Take one down, pass it around,
35 bottles of beer on the wall.

35 bottles of beer on the wall,
35 bottles of beer.
Take one down, pass it around,
34 bottles of beer on the wall.

34 bottles of beer on the wall,
34 bottles of beer.
Take one down, pass it around,
33 bottles of beer on the wall.

33 bottles of beer on the wall,
33 bottles of beer.
Take one down, pass it around,
32 bottles of beer on the wall.

32 bottles of beer on the wall,
32 bottles of beer.
Take one down, pass it around,
31 bottles of beer on the wall.

31 bottles of beer on the wall,
31 bottles of beer.
Take one down, pass it around,
30 bottles of beer on the wall.

30 bottles of beer on the wall,
30 bottles of beer.
Take one down, pass it around,
29 bottles of beer on the wall.

29 bottles of beer on the wall,
29 bottles of beer.
Take one down, pass it around,
28 bottles of beer on the wall.

28 bottles of beer on the wall,
28 bottles of beer.
Take one down, pass it around,
27 bottles of beer on the wall.

27 bottles of beer on the wall,
27 bottles of beer.
Take one down, pass it around,
26 bottles of beer on the wall.

26 bottles of beer on the wall,
26 bottles of beer.
Take one down, pass it around,
25 bottles of beer on the wall.

25 bottles of beer on the wall,
25 bottles of beer.
Take one down, pass it around,
24 bottles of beer on the wall.

24 bottles of beer on the wall,
24 bottles of beer.
Take one down, pass it around,
23 bottles of beer on the wall.

23 bottles of beer on the wall,
23 bottles of beer.
Take one down, pass it around,
22 bottles of beer on the wall.

22 bottles of beer on the wall,
22 bottles of beer.
Take one down, pass it around,
21 bottles of beer on the wall.

21 bottles of beer on the wall,
21 bottles of beer.
Take one down, pass it around,
20 bottles of beer on the wall.

20 bottles of beer on the wall,
20 bottles of beer.
Take one down, pass it around,
19 bottles of beer on the wall.

19 bottles of beer on the wall,
19 bottles of beer.
Take one down, pass it around,
18 bottles of beer on the wall.

18 bottles of beer on the wall,
18 bottles of beer.
Take one down, pass it around,
17 bottles of beer on the wall.

17 bottles of beer on the wall,
17 bottles of beer.
Take one down, pass it around,
16 bottles of beer on the wall.

16 bottles of beer on the wall,
16 bottles of beer.
Take one down, pass it around,
15 bottles of beer on the wall.

15 bottles of beer on the wall,
15 bottles of beer.
Take one down, pass it around,
14 bottles of beer on the wall.

14 bottles of beer on the wall,
14 bottles of beer.
Take one down, pass it around,
13 bottles of beer on the wall.

13 bottles of beer on the wall,
13 bottles of beer.
Take one down, pass it around,
12 bottles of beer on the wall.

12 bottles of beer on the wall,
12 bottles of beer.
Take one down, pass it around,
11 bottles of beer on the wall.

11 bottles of beer on the wall,
11 bottles of beer.
Take one down, pass it around,
10 bottles of beer on the wall.

10 bottles of beer on the wall,
10 bottles of beer.
Take one down, pass it around,
9 bottles of beer on the wall.

9 bottles of beer on the wall,
9 bottles of beer.
Take one down, pass it around,
8 bottles of beer on the wall.

8 bottles of beer on the wall,
8 bottles of beer.
Take one down, pass it around,
7 bottles of beer on the wall.

7 bottles of beer on the wall,
7 bottles of beer.
Take one down, pass it around,
6 bottles of beer on the wall.

6 bottles of beer on the wall,
6 bottles of beer.
Take one down, pass it around,
5 bottles of beer on the wall.

5 bottles of beer on the wall,
5 bottles of beer.
Take one down, pass it around,
4 bottles of beer on the wall.

4 bottles of beer on the wall,
4 bottles of beer.
Take one down, pass it around,
3 bottles of beer on the wall.

3 bottles of beer on the wall,
3 bottles of beer.
Take one down, pass it around,
2 bottles of beer on the wall.

2 bottles of beer on the wall,
2 bottles of beer.
Take one down, pass it around,
1 bottle of beer on the wall.

1 bottle of beer on the wall,
1 bottle of beer.
Take one down, pass it around,
No bottles of beer on the wall.

No bottles of beer on the wall,
No bottles of beer.
Go to the store, buy some more,
99 bottles of beer on the wall.")}"
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.