Login
|
Signup
langref.org
-
perl
,
cpp
,
csharp
, and
fantom
add..
all
clojure
erlang
fsharp
go
groovy
haskell
java
ocaml
php
python
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Structure
Loops
Perform an action a fixed number of times with a counter
Display the string
"10 .. 9 .. 8 .. 7 .. 6 .. 5 .. 4 .. 3 .. 2 .. 1 .. Liftoff!"
perl
for (my $i = 10; $i > 0; $i--) {
print "$i .. ";
}
print "Liftoff!";
for (my $i = 10; $i > 0; $i--) {
print "$i .. ";
}
print "Liftoff!";
perl
print "$_ .. " for reverse 1..10;
print "Liftoff!";
print "$_ .. " for reverse 1..10;
print "Liftoff!";
cpp
C++/CLI .NET 2.0
for(int i = 10; i != 0; --i) Console::Write("{0} .. ", i);
Console::WriteLine("Liftoff!");
using namespace System;
int main()
{
for(int i = 10; i != 0; --i) Console::Write("{0} .. ", i);
Console::WriteLine("Liftoff!");
}
csharp
for (int i = 10; i > 0; i--)
{
Console.Write("{0} .. ", i);
}
Console.WriteLine("Liftoff!");
for (int i = 10; i > 0; i--)
{
Console.Write("{0} .. ", i);
}
Console.WriteLine("Liftoff!");
fantom
(10..1).each { Env.cur.out.print("$it .. ") }
Env.cur.out.print("Liftoff!")
class SolutionXX
{
Void main()
{
(10..1).each { Env.cur.out.print("$it .. ") }
Env.cur.out.print("Liftoff!")
}
}
fantom
for (i := 10; i >= 1; i--)
Env.cur.out.print("$i .. ")
Env.cur.out.print("Liftoff!")
class SolutionXX
{
Void main()
{
for (i := 10; i >= 1; i--)
Env.cur.out.print("$i .. ")
Env.cur.out.print("Liftoff!")
}
}
Submit a new solution for
perl
,
cpp
,
csharp
, or
fantom
There are 16 other solutions in
additional
languages (
clojure
,
erlang
,
fsharp
,
groovy
...)