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

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

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

P03.ppt

Ruby Ruby ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( ) 44=>

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

r1.dvi

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

untitled

untitled

1 Ex Ex. 2 2

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

2


Microsoft PowerPoint - ruby_instruction.ppt

BASIC / / BA- SIC Web 1/10 1/10 / / JavaScript

Ruby 50 Ruby UTF print, \n [Ruby-1] print("hello, Ruby.\n") [Ruby-2] Hello, Ruby. [Ruby-3] print("hello, \"Ruby\".\n") 2 [Ruby-4] seisuu = 10 pr

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

Ruby演習テキスト1


8 if switch for while do while 2

LUCUA1100&LUCUA 1周年アニバーサリー! ~ルクア大阪が発信する新プロジェクト「LIFE」についてのご案内~

SP100 取扱説明書

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

untitled

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


fuga scanf("%lf%*c",&fuga); 改行文字を読み捨てる 10 進数の整数 おまじない取り込んだ値を代入する変数 scanf( %d%*c,&hoge); キーボードから取り込め という命令 1: scanf 1 1: int double scanf %d %lf printf

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

2

2



2

:30 12:00 I. I VI II. III. IV. a d V. VI

Microsoft PowerPoint - 11RubyIntro-No02.ppt [互換モード]

2 1/2 1/4 x 1 x 2 x 1, x 2 9 3x 1 + 2x 2 9 (1.1) 1/3 RDA 1 15 x /4 RDA 1 6 x /6 1 x 1 3 x 2 15 x (1.2) (1.3) (1.4) 1 2 (1.5) x 1

10 (1) s 10.2 rails c Rails 7 > item = PlanItem.new => #<PlanItem id nil, name nil,...> > item.name = "" => "" > item.valid? => true valid? true false

ruby novice ruby novice ruby novice.

情報科学概論 第1回資料

A/B (2018/06/08) Ver kurino/2018/soft/soft.html A/B

I 1 1 ( *) ( *) ex1-1.rb ) 2 CGI

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó

¥¢¥ë¥´¥ê¥º¥à¥¤¥ó¥È¥í¥À¥¯¥·¥ç¥ó ÎØ¹Ö #1

r9.dvi

Boost.Preprocessor でプログラミングしましょう DigitalGhost

kiso2-06.key

つくって学ぶプログラミング言語 RubyによるScheme処理系の実装

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó

コンピュータ概論

Microsoft PowerPoint - 13Kadai.pptx


Emacs Ruby..

javascript key

:30 12:00 I. I VI II. III. IV. a d V. VI

Swift1.key


Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

5-2 print(i, "\n") print("-- while--\n") while i < 2 j = print(i, ",", j, "\n") print("-- while--\n") while j < 3 print(i, ",", j, "\n") j = j + 1 pri

15 Phoenix HTML 15.1 ModestGreeter RAVT web/router.ex web/router.ex : 12 scope "/", ModestGreeter do 13 pipe_through :browser get "/", TopCont

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

r2.dvi

2

ohp1.dvi

K227 Java 2

Java演習(4) -- 変数と型 --

r08.dvi

double float

(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1

1

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C

橡Pro PDF

PPP_‚Ü‚Æ‚ß.pdf

I J

() / (front end) (back end) (phase) (pass) 1 2

2 3 Pockets Pockest Java [6] API (Backtracking) 2 [7] [8] [3] i == Pockets 2.1 C3PV web [9] Pockets [10]Pockets 1 3 C

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

I 11

Microsoft PowerPoint - 11RubyIntro.ppt

O(N) ( ) log 2 N

key

Perl入学式 #3

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

haskell.gby


ML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1

Java学習教材

79!! 21

PowerPoint プレゼンテーション

Microsoft Word - hozon-fujimura-HP-伊勢工業高校における造船教育の歴史から学ぶ

/

listings-ext

JavaScript Web JavaScript BitArrow BitArrow ( 4 ) Web VBA JavaScript JavaScript JavaScript Web Ajax(Asynchronous JavaScript + XML) Web. JavaScr


1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>


Python Speed Learning

r03.dvi

ohp08.dvi

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu

1Light Weight Language Light Weight Language Light Weight Language 5 2Perl Perl Perl PHP PHP PHP 34

Transcription:

I Exercise on Programming I http://bit.ly/oitprog1 12 of 14 ( RD S ) I 12 of 14 1 / 35

https://bit.ly/oitprog1 ( RD S ) I 12 of 14 2 / 35

game.rb ( RD S ) I 12 of 14 3 / 35

game.rb 11 ( ) 1 require "io/console" 2 require "timeout" 3 k = "" 4 x = 5 5 sp = 1 6 life = 3 7 score = 0 8 buf = [] 9 while true 10 buf.unshift(" " * rand(40) + "#" * (score / 15)) 11 buf = buf[0, 9] 12 puts(buf[0]) 13 print("\x1b7\x1b[33m\x1b[10a\x1b[#{x}co\x1b8\x1b[0m") 14 begin 15 Timeout.timeout(0.1) do 16 while true do 17 k = STDIN.getch 18 if k == " " && sp > 0 19 print("\x1b[9a\x1b[j\x1b8") 20 buf = [""] 21 sp = sp - 1 22 else 23 x = (x + (k == "h"? -1 : 1)) % 40 24 end 25 end 26 end 27 rescue 28 end 29 life = life - 1 if buf[-1][x] == "#" 30 break if life <= 0 31 score = score + 1 32 end 33 puts(score) ( RD S ) I 12 of 14 4 / 35

game.rb LIFE O o. ( RD S ) I 12 of 14 5 / 35

1 O #{".oo"[life]} print("\x1b( )[#{x}co\x1b8\x1b[0m") print("\x1b( )[#{x}c#{".oo"[life]}\x1b8\x1b[0m") ( RD S ) I 12 of 14 6 / 35

S t r i n g I n t e g e r variable str = gets.chomp val = gets.to_i.to_s.to_i if else end while end break ( RD S ) I 12 of 14 8 / 35

0 sumall_919???.rb e1919123@edu1: $ ruby sumall_919123.rb # 31 # 31 27 # 27-16 # -16 0 # 0 42 # 31+27+(-16)=42 e1919123@edu1: $ ( RD S ) I 12 of 14 9 / 35

sum = 0 while true x = gets.to_i break if x == 0 sum = sum + x end puts(sum) ( RD S ) I 12 of 14 10 / 35

1 sum = 0 2 while true 3 break if (x = gets.to_i) == 0 4 sum = sum + x 5 end 6 puts(sum) a = 123 123 x=gets.to_i ( RD S ) I 12 of 14 11 / 35

n

: n.times do end 10.times do puts("hello, world") end ( RD S ) I 12 of 14 13 / 35

n?.times do end a = gets.to_i a.times do i puts(i) end ( RD S ) I 12 of 14 14 / 35

times i break 5 10 (5..10).each do i end (5..10).each do i puts(i * 3) end ( RD S ) I 12 of 14 15 / 35

times times 0 99 3 0 + 3 + 6 + + 99 sum3_100.rb (5 ) e1x19123@edu2: $ ruby sum3_100.rb 1683 e1x19123@edu2: $ ( RD S ) I 12 of 14 16 / 35

(a.k.a. )

: x x = 10 puts("-" * x) puts(" " * (x - 1) + " ") puts("-" * x) e1x19123@edu2: $ ruby barchart.rb ---------- ---------- e1x19123@edu2: $ ( RD S ) I 12 of 14 18 / 35

: x x = 10 puts("-" * x) puts(" " * (x - 1) + " ") puts("-" * x) e1x19123@edu2: $ ruby barchart.rb ---------- ---------- e1x19123@edu2: $ ( RD S ) I 12 of 14 18 / 35

= def end def draw_bar x = 10 puts("-" * x) puts(" " * (x - 1) + " ") puts("-" * x) end ( RD S ) I 12 of 14 19 / 35

def draw_bar # x = 10 # puts("-" * x) # puts(" " * (x - 1) + " ") # puts("-" * x) # end # draw_bar draw_bar # 1 # 2 ( RD S ) I 12 of 14 20 / 35

barchart.rb ( RD S ) I 12 of 14 21 / 35

1: def draw_bar # end 10.times do # 10 draw_bar # end # ( RD S ) I 12 of 14 22 / 35

:! def draw_bar x = 10 puts("-" * x) puts(" " * (x - 1)) puts("-" * x) end def draw_bar(x) puts("-" * x) puts(" " * (x - 1) + puts("-" * x) end ( RD S ) I 12 of 14 23 / 35

: 2 draw_bar(10) draw_bar(3) draw_bar(8) x 10, 3, 8 ( RD S ) I 12 of 14 24 / 35

ok! def draw_bar(x, f) puts("-" * x) puts(f * (x - 1) + " " + x.to_s) puts("-" * x) end # f # f draw_bar(20, "/") draw_bar(8, " ") draw_bar(13, "X") ( RD S ) I 12 of 14 25 / 35

( ) ( ) / Q.? def hoge a = 0 b = 456 end a = 123 puts(a) hoge puts(a) puts(b) ( RD S ) I 12 of 14 26 / 35

220 110 bus_fare busfare.rb 0 e1x19123@edu2: $ ruby busfare.rb 2 # [ ] 2 3 # [ ] 3 770 # [ ] 770 0 # [ ] 0 4 # [ ] 4 440 # [ ] 440 0 # [ ] 0 0 # [ ] 0 e1x19123@edu2: $ ( RD S ) I 12 of 14 27 / 35

3 Fizz 5 Buzz 3 5 Fizz Buzz 3 5 fizz_buzz 0 49 Fizz Buzz fizzbuzz_x19???.rb ( x19??? wx ) ( RD S ) I 12 of 14 28 / 35

( ) ex919123@edu1: $ ruby fizzbuzz_x19123.rb # Fizz Buzz # 0 3 5 Fizz Buzz 1 2 Fizz # 3 3 Fizz 4 Buzz # 5 5 Buzz Fizz # 6 3 Fizz ( ) Fizz # 48 3 Fizz 49 e1919123@edu1: $ ( RD S ) I 12 of 14 29 / 35

fizzbuzz_x19???.rb Google classroom https://classroom.google.com https://edu1.rd. oit.ac.jp/prog1/selfcheck.rb selfcheck.rb ( RD S ) I 12 of 14 30 / 35

( RD S ) I 12 of 14 32 / 35

( )

1 def fizz_buzz(x) # end # 0 49 # fizz_buzz ( ) ( RD S ) I 12 of 14 34 / 35

2 def fizz_buzz(x) # end 50.times do i # end ( RD S ) I 12 of 14 35 / 35