File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
id/documentation/ruby-from-other-languages Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ Berikut ini adalah contoh program untuk menjumlahkan dua angka
42
42
(diinputkan dari keyboard) di C:
43
43
44
44
{% highlight python %}
45
- #include
45
+ #include <stdio.h>
46
46
47
47
int main(int argc, char * argv[ ] )
48
48
{
Original file line number Diff line number Diff line change @@ -22,7 +22,18 @@ menggunakan bahasa Perl:
22
22
23
23
{% highlight perl %}
24
24
$n = 5;
25
- sub bottle { my $n = shift; $n
25
+ sub bottle { my $n = shift; $n < 2 ? "$n bottle" : "$n bottles" }
26
+ while ($n) {
27
+ print <<"BOTOL";
28
+ ${\bottle $n} of beer on the wall
29
+ ${\bottle $n} of beer
30
+ Take one down, pass it around
31
+ ${\bottle --$n} of beer on the wall
32
+
33
+ BOTOL
34
+ }
35
+
36
+ print "No more beer on the wall :-(\n";
26
37
{% endhighlight %}
27
38
28
39
Program tersebut dapat ditulis sebagai berikut di Ruby: \*
You can’t perform that action at this time.
0 commit comments