Windows [ ] [ (R)..] cmd [OK] Z:\> mkdir progi [Enter] \ ) mkdir progi ) (command ) help [Enter] help ( help ) mkdir make directory Windows ) mkdir mk

Similar documents
Windows Cygwin Mac *1 Emacs Ruby ( ) 1 Cygwin Bash Cygwin Windows Cygwin Cygwin Mac 1 Mac 1.2 *2 ls *3 *1 OS Linux *2 *3 Enter ( ) 2

dynabookガイド

ruby novice ruby novice ruby novice.

parser.y 3. node.rb 4. CD-ROM

Python Speed Learning

untitled

GNU Emacs GNU Emacs

Emacs Ruby..

dynabookガイド

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

リファレンス

Python Speed Learning

X Window System X X &

インターネット入門

第117期報告書

超初心者用

DF-200

listings-ext

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

untitled

コンバートスター15シリーズ 製品パンフレット

ジェネリック医薬品販売会社(田辺製薬販売株式会社)の設立に伴う包装変更のご案内

06地図目録.pwd

17. (1) 18. (1) 19. (1) 20. (1) 21. (1) (3) 22. (1) (3) 23. (1) (3) (1) (3) 25. (1) (3) 26. (1) 27. (1) (3) 28. (1) 29. (1) 2

解きながら学ぶC言語

CD-ROM Ver.1Ver

PC STATION S200L seriesファーストステップガイド

p1

untitled

明解Java入門編

オンラインマニュアル

MPC-816ファミリ


2

RQT7440-5S

tebiki00.dvi

P03.ppt

CX-G6400 ユーザーズガイド

Microsoft PowerPoint - InfPro_I6.pptx

C言語によるアルゴリズムとデータ構造

DEMO OFF v a

CLOCK/ AUTO OFF TIMER SLEEP DISPLAY DISC ABC DEF TITLE SEARCH GHI JKL MNO TITLE IN CHARA PQRS TUV WXYZ AREA ENTER PROGRAM SPACE! # D

Microsoft PowerPoint - Borland C++ Compilerの使用方法(v1.1).ppt [互換モード]

nakao

help gem gem gem my help

Excel97関数編

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

I #2 : ( 8-13), () URL : j inoue/prog2007/prog2007.html

2.4.7 \ AWK AWK......

1st-session key

Numerical Rosetta Stone 1 C, Java, Perl, Ruby, Python [ ] Hello world C: /* hello.c $> gcc hello.c $>./a.out */ #include <stdio.h> main(){ printf("hel

本 日 の 授 業 内 容 最 低 限 覚 えるべきUNIXコマンド pwd, ls, mkdir, cd, cp, rm, mv テキストエディタの 簡 単 な 使 い 方 テキストエディット, Jedit X,Emacs C 言 語 プログラミングの 初 歩 hello, world を 画 面

Express5800/340Hb-Rユーザーズガイド(セットアップ編)

Transcription:

Ruby I I 1 Windows 1 Meadow 1: Meadow I Meadow 2 2 Ruby 2.1 I Z progi 1

Windows [ ] [ (R)..] cmd [OK] Z:\> mkdir progi [Enter] \ ) mkdir progi ) (command ) help [Enter] help ( help ) mkdir make directory Windows ) mkdir mkdir progi progi 1. 2. help [Enter] 3. help mkdir mkdir 4. cd dir move del copy 5. mkdir progi progi 2

2.2 (source program) 1 \ ) ) ) 1 print("hello, Ruby!\n") 2 print("hello, Ruby!\n") 2: Hello, Ruby! 2 Hello, Ruby! Hello, Ruby! hello.rb (suffix).rb ruby Z:\> \ ) ) cd progi [Enter] dir [Enter] progi hello.rb) ruby hello.rb (ruby ) Z:\>cd progi Z:\progI>dir... Z:\progI>ruby hello.rb 1 3

Hello, Ruby! Hello, Ruby! cd change directory Windows ) cd cd progi progi dir list directory dir <DIR> print Ruby "Hello, Ruby!\n" \n (") 1. Meadow 2. 2 Meadow ( 3. Z:\progI hello.rb 4. cd progi [Enter] Z progi ( cd progi ) 5. (> [Enter] ( : rubyhello.rb ) Z:\>cd progi Z:\progI>dir...... Z:\progI>ruby hello.rb Hello, Ruby! 2 4

2.3 (?) 2 2 ) ruby hello.rb 3 hello.rb:2: syntax error, unexpected $, expecting ) 3: "hello.rb" 2 2 syntax error, unexpected $, expecting ) $ ) ( ) 2 2 ) 1 2.4 tab 1 x = 10 2 3 if x == 10 4 print("x 10 \n") 5 else 6 print("x 10 \n") 7 4: sample0.rb sample0.rb 4 2 print 2 5

(indent) Meadow Ruby mode Meadow Ruby (.rb ) Ruby mode tab C-x h ESC C-\ sample0.rb 4 tab 4 6 C-x h ESC C-\ sample0.rb 3 Ruby (programming, ) 1. 2 print \n 2. 5 Ruby (suffix).rb 6

print("h") print("e") print("l") print("l") print("o\n") print("hello\n") 5: sample1.rb puts("hello") 6: sample2.rb print(2 + 3, "\n") print(2-3, "\n") print(2 * 3, "\n") print(2 / 3, "\n") print(2 ** 3, "\n") print(math.sin(3.14), "\n") print(math.sqrt(2), "\n") 7: sample3.rb print("hello\n") print("hello" + "ruby\n") print("hello" + " ruby" + " world!\n") 8: sample4.rb print("hello\n") print("hello" * 4 + "\n") 9: sample5.rb 7

a = 3 print(a, "\n") a = 3 b = 4 print("a = ", a, ",b = ", b, "\n") 10: sample6.rb a = 2 b = 3 11: sample7.rb print(a, " + ", b, " = ", a + b, "\n") print(a, " - ", b, " = ", a - b, "\n") print(a, " * ", b, " = ", a * b, "\n") print(a, " / ", b, " = ", a / b, "\n") i = 1 print("i = ", i, "\n") print("i = ", i, "\n") print("i = ", i, "\n") 12: sample8.rb 13: sample9.rb # 1 30 i = 1 while i <= 30 print(i, "\n") 14: sample10.rb 8

i = 0 while i < 10 print(i + 1, " \n") 15: sample11.rb print("hello!") print("hello!") print("hello!") print("-----\n") i = 0 while i < 3 print("hello!!") 16: sample12.rb # * i = 1 while i <= 10 j = 1 while j <= i print("*") j = j + 1 print("\n") 17: sample13.rb 9

# 1 10 total = 0 total = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 print("total = ", total, "\n") sum = 0 i = 1 while i <= 10 sum = sum + i print("sum = ", sum, "\n") 18: sample14.rb sum = 0 i = 0 x = [10, 20, 35, 40, 50] while i < x.length sum = sum + x[i] print("sum = ", sum, "\n") 19: sample15.rb 10

puts(" 1 120 ") puts(" ") n = gets.chomp.to_i if n > 120 print(" 1 ", n - 120, " \n") elsif n == 120 print(" 1 \n") else print(120 - n, " \n") 20: sample16.rb sushi = {" " => 100, " " => 300, " " => 200} print(sushi[" "], "\n") print(sushi[" "], "\n") print(sushi[" "], "\n") 21: sample17.rb def hello(name) print(name, " \n") hello(" ") hello(" ") hello(" ") 22: sample18.rb 11

( ) http://klis.tsukuba.ac.jp/klib/subjects/progi/text/zu1.gif sample19.rb Enter require sdl print("?") n = gets.chomp.to_i SDL.init(SDL::INIT_VIDEO) screen = SDL.setVideoMode(300, 600, 16, SDL::SWSURFACE ) # interval = 1 i = 0 while i < n loop_start = SDL.getTicks/1000.0 x = i % 3 * 100 y = 500 - (i /3)*50 chara = SDL::Surface.load( zu1.gif ) screen.put(chara, x, y) screen.updaterect(0, 0, 0, 0) print(" ", i + 1, "..."); sleep(1.8) if i >= 29 print("............") break print("\n..................\n") sleep(6) print("\n\n\n") print(" \n") 23: sample19.rb 12