http://99-bottles-of-beer.net/lyrics.html
여기의 1씩 감소하는 형태의 노래가사를 프로그래밍으로 짜라고 했더니..
C가 아래처럼 하니까
============================================================
#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;
}
=====================================================================
파이썬은 이렇게 짜는 센스
a,t=\"\\n%s bottles of beer on the wall\",\"\\nTake one down, pass it around\"
for d in range(99,0,-1):
print(a%d*2)[:-12]+t+a%(d-1 or\'No\')
맥주좀사줘
파이썬버젼은 가사가 좀 바뀌는듯
http://codepad.org/Acr4FtVD
아무리생각해도 펄은 참 신기한 언어임 \'ㅅ\';