전체 글 724

구구단 풀력 예제 for Ruby and JRuby

Ruby 언어의 함수 정의 구문 양식은 def functionName(parameters) block end 이다. 또 Ruby 언어의 전형적인 for 반복문 양식은 for varName in Range block end 이다. 소스 파일명: forTest.rb ------------------------------[소스 시작] def printDan(dan) for i in 1..9 print "#{dan} x #{i} = #{dan*i}\n" end end printDan(2) ------------------------------[소스 끝] 실행> ruby forTest.rb (또는 jruby forTest.rb) 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 =..

구구단 출력 예제 for Python and Jython

Python(및 Jython) 언어의 함수 정의 구문 양식은 def functionName(parameters): block 이다. 또 Python(및 Jython) 언어의 반복문 양식은 for varName in Range: block 이다. 소스 파일명: forTest.py ------------------------------[소스 시작] def printDan(dan): for i in range(1, 10): print "%d x %d = %d" % (dan, i, dan*i) printDan(2) ------------------------------[소스 끝] 실행> python forTest.py (또는 jython forTest.py) 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6..

구구단 출력 예제 for Groovy

Groovy 언어의 함수 정의 구문 양식은 def functionName(parameters) { block } 이다. 또 Groovy 언어의 전형적인 for 반복문 양식은 for (varName in Range) { block } 이다. 소스 파일명: ForTest.groovy ------------------------------[소스 시작] def printDan(dan) { for (i in 1..9) { println( "$dan x $i = ${dan*i}" ) } } printDan(2) ------------------------------[소스 끝] 실행> groovy ForTest.groovy 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2..

각종 스크립트 언어의 대화형 모드에서 구구단 표의 한 단 출력하기

1. Groovy 언어의 대화형 모드에서 구구단의 2단표 출력하기 Command> groovysh Groovy Shell (1.5.4, JVM: 1.5.0_14-b03) Type 'help' or '\h' for help. ---------------------------------------------------------------------------- groovy:000> x = 2 ===> 2 groovy:000> for (i in 1..9) { groovy:001> println("$x x $i = ${x*i}") groovy:002> } 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x..

카테고리 없음 2008.02.17

각종 스크립트 언어의 대화형(ineractive) 모드에서 9*9의 값을 출력하기

1. Groovy 언어어 대화형 모드 Command> groovysh Groovy Shell (1.5.4, JVM: 1.5.0_14-b03) Type 'help' or '\h' for help. -------------------------------------------- groovy:000> println(9*9) 81 ===> null groovy:000> exit 2. Ruby 언어어 대화형 모드 Command> irb irb(main):001:0> print "%d\n" % (9*9) 81 => nil irb(main):002:0> exit 3. JRuby 언어어 대화형 모드 Command> jirb irb(main):001:0> print "%d\n" % (9*9) 81 => nil irb(m..

카테고리 없음 2008.02.17

각종 스크립트(또는 컴파일) 언어 환경의 버전 알아보기 명령

Command> jython --version Jython 2.2.1 on java1.5.0_14 Command> python -V Python 2.5.1 Command> ruby -v ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] Command> jruby -v ruby 1.8.5 (2007-12-15 rev 5200) [x86-jruby1.0.3] Command> lua -v Lua 5.1.3 Copyright (C) 1994-2008 Lua.org, PUC-Rio Command> ch -v Ch Professional edition, version 5.5.0.13261 (C) Copyright 2001-2006 SoftIntegration, Inc. h..

카테고리 없음 2008.02.17

구구단 출력 예제 for Lua

lua 언어의 for 반복문 양식은 for varName = startValue, endValue, stepValue do block end 또는 for varName = startValue, endValue do block end 이다. 또 문자열이나 자료의 붙이기(concatenation) 연산자는 .. 이다. (즉 두 개의 점) ' 소스 파일명: for_test.lua ------------------------------[소스 시작] local function printDan(dan) for i = 1, 9 do print( dan .. " x " .. i .. " = " .. (dan*i) ) end end printDan(2) ------------------------------[소스 끝] ..

프로그래밍/Lua 2008.02.13

Visual C++ 2005 Express Edition로 Win32 어플리케이션 만들기

Visual C++ 2005 Express Edition에서 Win32어플리케이션을 만들기위해서는 몇가지 설정을 해주어야된다. 1) 먼저 Visual C++ 2005 Express Edition 다운로드해서 셋업한다. 2) Microsoft Platform SDK를 다운로드해서 셋업한다. 3) 패스를 설정한다. Visual C++ 2005 Express Edition을 시작해서 툴 > 옵션 > 프로젝트 및 솔루션 > VC++ 디렉토리에 Microsoft Platform SDK의 Bin, Includem lib의 패스를 추가한다. 4) 라이브러리 추가 C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults \corewin_express.vsprop..

프로그래밍/C++ 2008.02.13

Hello 예제 for Python

컨솔에 문자 출력하는 python 구문은 print "문자열(스트링)" 이다. 여기서 개행문자 "\n"은 추가하지 않아도 된다. (Jython의 문자 출력 구문도 위와 같다.) 소스 파일명: hello.py ------------------------------[소스 시작] print "Hello, world!" ------------------------------[소스 끝] 실행> python hello.py Hello, world! * Jython으로 실행하는 경우: 실행> jython hello.py Hello, world! * IronPython으로 실행하는 경우: 실행> ipy hello.py Hello, world!