U E D R , A S I H C RSS

인수/Smalltalk

~cpp 
from: aFrom to: aTo
	| a b |
	a := aFrom.
	b := 1.
	[a <= aTo] whileTrue: [
		[b <= 9] whileTrue:[
			Transcript cr; show: a; show: ' * '; show: b; show: ' = '; show: a*b; printString.
			b := b + 1.
		].
		a := a + 1.
		b := 1.
		Transcript cr.
	].
  • 히...

  • .--; ... --; .;;

~cpp 
RWBoard>>initialize: aSize
	size := aSize.
	numsOfWalked := Array2D width:size height:size.
	numsOfWalked atAllPut:0.

RWBoard>>isAllPut
	numsOfWalked do: [ :val | val = 0 ifTrue: [^false] ].
	^true.
		
RWBoard>>row: aRow col: aCol
	| numOfWalked |
	numOfWalked _ numsOfWalked at: aRow at: aCol.
	numsOfWalked at: aRow at:aCol put: numOfWalked + 1.

RWBoard>>setValidLocation: num
	| newValue |
	newValue := num + 3 atRandom - 2.
	newValue = 0 ifTrue: [newValue := 1].
	newValue = (1 + size) ifTrue: [newValue := size].
	^newValue.

RWBoard Class>>make: aSize
	^self new initialize:aSize.
~cpp 
RWRoach>>abroad: aBoard row: aRow col: aCol
	totalWalked := 1.
	curRow _ aRow.
	curCol _ aCol.
	aBoard row: aRow col: aCol.

RWRoach>>moveOne: aBoard
	totalWalked _ totalWalked + 1.
	self selectDirection: aBoard.
	aBoard row:curRow col:curCol.
	
RWRoach>>selectDirection: aBoard
	curRow := aBoard setValidLocation: curRow.
	curCol := aBoard setValidLocation: curCol.

RWRoach>>traverse: aBoard
	[ aBoard isAllPut = false. ] whileTrue: [ self moveOne:aBoard. ].

~cpp 
b := RWBoard make:5.
r := RWRoach new.
r abroad:b row:1 col:1.
r traverse:b.
  • : 토크 . C++/Java . . . .( . 팩토 . .--;) do .
  • . ㅠ.ㅠ ... 흑 ㅠ.ㅠ
  • .--;
  • 2 . . .
  • SBPP .


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:35
Processing time 0.0097 sec