| | |
500 ways to print [1..10]!
![]() |
*Hopefull this hasn't been done already*
Write a program that when run, will print out the numbers 1 through 10. The program can be in any language, and can be as complicated or simple as you want.
Lets see how creative people are, and get up to 500 unique ways!
I'll start out with something simple:
C++
EDIT: I guess we'll let the post count determine the number of different ways that have been produced.
Write a program that when run, will print out the numbers 1 through 10. The program can be in any language, and can be as complicated or simple as you want.
Lets see how creative people are, and get up to 500 unique ways!
I'll start out with something simple:
C++
#include <iostream>
int main() {
int x = 1, y = 10;
while(y--)
std::cout << x++ << std::endl;
}EDIT: I guess we'll let the post count determine the number of different ways that have been produced.
--Jessehk
C#
using System;
class onetoten
{
public static void Main ()
{
for (int x = 0; x < 11; x++)
{
Console.Write(x);
}
}
} Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Scheme
(define range
(lambda (s e)
(cond ((< s e) (cons s
(range (+ s 1) e)))
((= s e) (list s))
(else "Invalid function call"))))
(range 1 10) ;=> (1 2 3 4 5 6 7 8 9 10) --Jessehk
3.) VB Script
MsgBox "1, 2, 3, 4, 5, 6, 7, 8, 9, 10", vbOKOnly, "Count!"
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
C++
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
int main() {
std::vector<int> numbs(0);
for(int x = 1; x <= 10; x++)
numbs.push_back(x);
std::copy(numbs.begin(), numbs.end(), std::ostream_iterator<int>(std::cout, "\n"));
} --Jessehk
•
•
•
•
Originally Posted by tayspen
C#
using System; class onetoten { public static void Main () { for (int x = 0; x < 11; x++) { Console.Write(x); } } }
using System;
using System.Collections.Generic;
using System.Text;
namespace counting
{
public class Counter
{
private int count = 1;
public int Count
{
get
{
return count;
}
set
{
count = value;
}
}
}
class Program
{
public static void Main()
{
Counter number = new Counter();
do
{
Console.WriteLine(number.Count.ToString());
number.Count++;
} while (number.Count <= 10);
}
}
}Looks like a lot more code... Well, it is, but now I've created a reusable object that does all of the work, and I could change it later on so to have a different starting number, or even determine the number some other way.
Alex Cavnar, aka alc6379
That is indeed a better way you did it though. But alot more code 
Another one; Doesnt really 'count" but it prints .
C#
Yea, it's beginner, yet it gets the job done. Now off to create a complicated one.
Jess, was this thread inspire by the one on PFO
.

Another one; Doesnt really 'count" but it prints .
C#
MessageBox.Show("1, 2, 3, 4, 5, 6, 7, 8, 9, 10");Yea, it's beginner, yet it gets the job done. Now off to create a complicated one.
Jess, was this thread inspire by the one on PFO
. Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Perl:
print "$_\n" for 1..10
All my posts may be redistributed under the GNU Free Documentation License.
FASM Assembly:
format PE console
entry start
include 'C:\fasmw\include\win32a.inc'
;======================================
section '.data' data readable writeable
;======================================
num_fmt db '%d',10,0
;=======================================
section '.code' code readable executable
;=======================================
start:
mov ebx,10
.again:
lea eax,[ebx-11]
neg eax
ccall [printf],num_fmt,eax
dec ebx
jnz .again
stdcall [ExitProcess],0
;=====================================
section '.import' import data readable
;=====================================
library kernel,'kernel32.dll',\
msvcrt,'msvcrt.dll'
import kernel,\
ExitProcess,'ExitProcess'
import msvcrt,\
printf,'printf' I'm here to prove you wrong.
![]() |
Other Threads in the IT Professionals' Lounge Forum
- Previous Thread: Merrrrryyyyy Christmas!
- Next Thread: creating skins
| Thread Tools | Search this Thread |
1gbit advertising advice amazon archive british broadband business businessprocesses career carrier censorship cern china cio collectiveintelligence connectivity consumer consumers corporateearnings datatransfer debtcollectors dictionary digg digital ebay ecommerce email employment environment facebook food government grid high-definition hottub infodelivery infotech intel internet interview ipod isp japan kindle lhc library malware marketing mit moonfruit news onlineshopping piracy piratebay pope porn program r&d religion remoteworking research retail security sex shopping simple skype smallbusiness smb sms socialmedia socialnetworking software softwareengineer spam speed spending startrek statistics stocks study stumbleupon survey tabletpc technology touch-screen touchscreen twitter uk videoinprint voips web webdeveloper windows words






