ããããçå£ã«ãããæ¥ãä»äºã§èª°ããåè«ã§gopèšèªãæžãããšãææ¡ããŠãã ãã§ãããã°ã©ããŒã®ããã«æããããšãã§ããããã«ããŸããã ãchoããšããåèªãšãã®ãã¹ãŠã§æ§ç¯ãéå§ããŸãã ããã§ãã³ã³ãã¥ãŒã¿ãµã€ãšã³ã¹ã®åéã§ç§ã®äººçã®éã®ãã®æè²ã«åºäŒã£ãŠããªãã®ã§ãã³ã³ãã€ã©ãã«ãã£ã³ã°ãæ£åŒãªææ³ãããã³2幎ç®ãŸãã¯3幎ç®ã«æ®éã®åŠçãé£ã¹ããã®ä»ã®èå³æ·±ãã³ãŒã¹ãã¹ãŠãèŠéããããšã«æ³šæããŠãã ããã ã³ã³ãã€ã©ã®æ§ç¯ã«é¢ããWirthã®æ¬ã¯ãBNFãªã©ã®ããããçš®é¡ã®å·§åŠãªçšèªã®ç¥èãè¿œå ããŸããããå®éçãªå©ç¹ã¯ãããŸããã§ãã-ç§ã¯åäžã®ã³ã³ãã€ã©ãæžããããšããããŸããã ãããã£ãŠããã®ã¿ã¹ã¯ã¯ç§ã«ãšã£ãŠéåžžã«èå³æ·±ããã®ã§ããã
ããªãã18æ³ä»¥äžã®å Žåãç§ãã¡ã®æ¯åœèªã®ãããã€ãªèªåœãé©åã«èªèããŠãããã©ãããå§ããããã«èå³ããããªããç«ã«ããããã
ææ³ãæäœããããã®ãã¹ãŠã®ããŒã«ã®äžã§ãç§ã¯ã»ãã®å°ãã ãèšåããŸããã ãŸã第äžã«ããããã¯ãã¡ããlexãflexãyaccãbisonãantlrã§ãããäž»ã«C / C ++ã³ã³ãã€ã©ãŒã«äœ¿çšãããŸãã 第äºã«ãããã¯ocamllexãšocamlyaccã§ãããããã¯ããæ³åã®ãšãããokamlaã§ã³ã³ãã€ã©ãŒãéçºããããã«èšèšãããŠããŸãã ãããŠç¬¬äžã«ãããã¯fslexxãšfsyaccã§ã-FïŒèšèªã«ã€ããŠã®ã¿åãããšã§ããããã¯ocamlããå®å šã«å°ãã³ããŒãããŸããããã®åŸããªãå€ãã®ã°ããºã§çãèããŸãã FïŒç§ã¯èªåã®ã·ã¹ãã ã«æ¬ åžããŠãããšããŠåŽäžããŸããã ã¯ããæã«ã¯å¹ åºãéžæãæªãããšããããŸããããããã¹ãŠã®ã¬ã¯ãµãŒãšããŒãµãŒã§æ··ä¹±ããã®ãæããŠããŸããã
ã¡ãªã¿ã«ãããã¯ç§ã«ãšã£ãŠããªãå¥åŠã§äžå¿«ãªçºèŠã§ãããèšèªã®åæã¯ãç°ãªãããŒã«ã§å®è¡ããã2ã€ã®å¥ã ã®æ®µéã§æ§æãããŠããããšãããããŸããã ããããæ²ããããªã
èšèªã®çš®é¡
åãã€ãããšã¯ãããŸãããããã«èšèªã®ã¢ãŒããã¯ãã£å šäœãèããããã§ã¯ãªããåŸã ã«æ©èœãåŸã ã«ä»äžããŠãããŸããã ããããçŽ æã®ãµã€ãºãå°ããããããã«ïŒãããŠã6ã€ã®çŸããæ¥ææ¥ã®æã®æéã«ç§ãé£ããŠè¡ã£ãéã«çŽ æ©ãè¡ãããã«ïŒããã¹ãŠãäºåã«èšç»ããããµããããŸãã ç§ãã¡ã®èšèªã®ååœä»€ã¯ãäŸãã°ããªããžã§ã¯ãã§ãã C ++ã§ã¯ãç¹å®ã®åœä»€åºæ¬ã¯ã©ã¹ã®åå«ã®1ã€ãšããŠãè€éãªæ§é ãšããŠããŸãã¯äžè¬çã«ã¯ãŠããªã³ãšããŠè¡šçŸã§ããŸãã 幞ããªããšã«ãokamlã䜿çšãããšãã§ããã ãç°¡åã«ãã¹ãŠãå®è¡ã§ããŸãã æåã®ãã¡ã€ã«ãyobaType.mlã¯ãèãããããã¹ãŠã®ã¿ã€ãã®æ瀺ãèšè¿°ããŠãããå¯èœãªéãã·ã³ãã«ã«èšèšãããŠããŸãã
type action =
DoNothing
| AddFunction of string * action list
| CallFunction of string
| Stats
| Create of string
| Conditional of int * string * action * action
| Decrement of int * string
| Increment of int * string;;
åèšèªæ§æäœã¯ããããã®ã¿ã€ãã®ããããã«ãã£ã¹ããããŸãã DoNothingã¯åãªãNOPã¹ããŒãã¡ã³ãã§ããããŸã£ããäœãããŸããã Createã¯å€æ°ãäœæããŸãïŒãããã¯åžžã«æŽæ°ã§ãïŒãDecrementãšIncrementã¯ãããããæå®ãããå€æ°ãããæ°ã ãå¢æžããŸãã ããã«ãäœæããããã¹ãŠã®å€æ°ãšæ¡ä»¶ä»ãã®çµ±èšæ å ±ã衚瀺ããçµ±èšããããŸããifå®è£ ã§ã¯ãç¹å®ã®å€æ°ã«å¿ èŠãªå€ïŒãŸãã¯å€§ããªå€ïŒãå«ãŸããŠãããã©ããã確èªã§ããŸãã æåŸã«ãAddFunctionãšCallFunctionãè¿œå ããŸãããããã¯ãå®éã«ã¯éåžžã«ããã·ãŒãžã£ã§ããç¬èªã®é¢æ°ãäœæããŠåŒã³åºãæ©èœã§ãã
èšèªã®ææ³
次ã®ã¹ãããã¯ãææ³ãã€ãŸãããçš®ã®æ瀺ã«å€ããèšèªã®æ§æãèšè¿°ããããšã§ãã
ã³ãŒãã衚瀺ããåã«ãç§ãã¡ã®èšèªãã©ã®ããã«æ©èœãããã説æããŸãã çµ±èšã®ã¯ãšãªïŒããã¯ãµãŒãã¹ããŒã ã®ãããªãã®ã§ãïŒãšé¢æ°ã®äœæãé€ããã¹ãŠã®ãã¶ã€ã³ã¯ãããŒã¯ãŒãã§å§ãŸããããŒã¯ãŒãã§çµãããŸãã ããã«ãããå¿ èŠã«å¿ããŠå®å šã«æ¹è¡ãšã€ã³ãã³ããé 眮ã§ããŸãã ããã«å ããŠïŒãã·ã¢èªã§äœæ¥ããŠããŸãïŒãå€æ°ãšå€ã®äž¡æ¹ãæž¡ãå¿ èŠãããå Žåã®ããã«ãããã€ãã®æé ãå ·äœçã«äœæããŸããã ãªããããå¿ èŠã ã£ãã®ãã¯åŸã§ããããŸãã ãã®ãããyobaParser.mlyãã¡ã€ã«ïŒ
%{
open YobaType
%}
%token <string> ID
%token <int> INT
%token RULEZ
%token GIVE TAKE
%token WASSUP DAMN
%token CONTAINS THEN ELSE
%token FUCKOFF
%token STATS
%token MEMORIZE IS
%token CALL
%start main
%type <YobaType.action> main
%%
main:
expr { $1 }
expr:
fullcommand { $1 }
| MEMORIZE ID IS fullcommandlist DAMN { AddFunction($2, $4) }
fullcommandlist:
fullcommand { $1 :: [] }
| fullcommand fullcommandlist { $1 :: $2 }
fullcommand:
WASSUP command DAMN { $2 }
| STATS { Stats }
command:
FUCKOFF { DoNothing }
| GIVE ID INT { Increment($3, $2) }
| GIVE INT ID { Increment($2, $3) }
| TAKE ID INT { Decrement($3, $2) }
| TAKE INT ID { Decrement($2, $3) }
| RULEZ ID { Create($2) }
| CALL ID { CallFunction($2) }
| CONTAINS ID INT THEN command ELSE command { Conditional($3, $2, $5, $7) }
| CONTAINS INT ID THEN command ELSE command { Conditional($2, $3, $5, $7) }
%%
æåã«è¡ãããšã¯ãèŠåºããæ¿å ¥ããããšã§ããæåã«èª¬æããã¢ã¯ã·ã§ã³ã¿ã€ããå«ãYobaTypeã¢ãžã¥ãŒã«ãéããŸãã èšèªïŒå€æ°ïŒã®ããŒã¯ãŒãã§ã¯ãªãæ°åãšæååã®å Žåã2ã€ã®ç¹å¥ãªåã宣èšããŸãããããã¯ãããããäœãå«ãããæ£ç¢ºã«ç€ºããŸãã ïŒ ããŒã¯ã³ãã£ã¬ã¯ãã£ãã䜿çšããããŒã¯ãŒãããšã«ãææ³ã§ãã®åèªãèå¥ããç¬èªã®ã¿ã€ããäœæããŸãã ãããã®ãã¹ãŠãå°ãªããšã1è¡ã§ç€ºãããšãã§ããŸãããã®ãããªã¬ã³ãŒãã¯ãåœä»€ã®ã¿ã€ãã«åŸã£ãŠãã¹ãŠãã°ã«ãŒãåããŸãã äœæãããã¹ãŠã®ããŒã¯ã³ã¯ãææ³ããŒãµãŒãå®è¡ãã¹ãå 容ã決å®ããæ£ç¢ºãªçœ®æã¿ã€ãã§ããããšã«æ³šæããŠãã ããã ãããã¯ããªãã奜ããªãã®ãããããèšèªèªäœã§ã©ã®ããã«èŠãããããšåŒã¶ããšãã§ããŸããããã«ã€ããŠã¯åŸã§èª¬æããŸãã ææ³ã®ãšã³ããªãã€ã³ããã¡ã€ã³ã§ãããã¢ã¯ã·ã§ã³ã¿ã€ãã®ãªããžã§ã¯ãã¯åžžã«ãããè¿ãå¿ èŠãããããšãã€ãŸããã€ã³ã¿ããªã¿ãžã®æ瀺ã§ããããšã瀺ããŸãã æåŸã«ã2ã€ã®%%èšå·ã®åŸãææ³èªäœã«ã€ããŠèª¬æããŸãã
- åœä»€ã¯ãã³ãã³ãïŒãã«ã³ãã³ãïŒãŸãã¯é¢æ°ã®äœæã§æ§æãããŸãã
- ãã®é¢æ°ã¯ãã³ãã³ãã®ãªã¹ãïŒfullcommandlistïŒã§æ§æãããŠããŸãã
- ã³ãã³ãã¯ããµãŒãã¹ïŒSTATSïŒãŸãã¯éåžžïŒã³ãã³ãïŒã®ããããã§ãããã®å ŽåãããŒã¯ãŒãã§ã©ããããå¿ èŠããããŸãã
- æ®éã®ããŒã ã§ã¯ããã¹ãŠãã·ã³ãã«ã§ããã€ã³ãããããŸããã
äžãã£ãã§ã¯ãæååããã®ãªãã·ã§ã³ã«äžèŽããå Žåã®åŠçââã瀺ããŸãã$ Nã¯ãæ§é ã®Nçªç®ã®ã¡ã³ããŒã瀺ããŸãã ããšãã°ããCALL IDãïŒIDã¯æååã§ããå¿ããªãã§ãã ããïŒãæºããå ŽåãCallFunctionåœä»€ãäœæãããã©ã¡ãŒã¿ãŒ$ 2ïŒIDã®ã¿ïŒ-åŒã³åºãããé¢æ°ã®ååãšããŠæž¡ããŸãã
ã¬ã¯ãµãŒ-èšèªãããŒã¯ãŒãã«å€ãã
åæã«ãæãåçŽã§æãéå±ãªéšåã«å°éããŸããã èšèªã®åèªããããŒã¯ã³ãžã®å€æãèšè¿°ããã ããªã®ã§ãç°¡åã§ãã é¢åãªã®ã¯ãåå¥è§£æåšïŒãŸãã¯ãªã«ã ããã¹ããŒåå¥è§£æåšã®ã¿ïŒããã·ã¢èªã§åäœããããã«ååã«èšèšãããŠããªããããæååãšåæ§ã«ãã·ã¢èªã®æåã§ããåäœã§ããªãããã§ãã èšèªã®ããŒã¯ãŒãã®å€§æåãšå°æåãåºå¥ããªãããã«ãããã£ãã®ã§ãããã¯hemoã®æãè¿œå ããŸãã-ãäžãããã ããæžãã®ã§ã¯ãªããæåããšã«ã¹ãã«ãªãã·ã§ã³ããã€ã³ãããå¿ èŠããããŸããã äžè¬çã«ã¯ãyobaLexer.mllãã¡ã€ã«ãã芧ãã ããã
- {
- YobaParserãéã
- äŸå€ eof
- }
- ã«ãŒã«ããŒã¯ã³=解æ
- ïŒ "and" | "And" ïŒ ïŒ "d" | "D" ïŒ ïŒ "and" | "And" ïŒ ïŒ ' ' ïŒ +
- ïŒ "n" | "H" ïŒ ïŒ "a" | "A" ïŒ ïŒ "x" | "X" ïŒ ïŒ "y" | "Y" ïŒ ïŒ "y" | "Y" ïŒ { FUCKOFF }
- | ïŒ "b" | "B" ïŒ ïŒ "a" | "A" ïŒ ïŒ "l" | "L" ïŒ ïŒ "a" | "A" ïŒ
- ïŒ "n" | "H" ïŒ ïŒ "c" | "C" ïŒ ïŒ ' ' ïŒ +
- ïŒ "n" | "H" ïŒ ïŒ "a" | "A" ïŒ ïŒ "x" | "X" ïŒ {çµ±èš}
- | [ ' ' ' \ t ' ' \ n ' ' \ r ' ] {ããŒã¯ã³lexbuf }
- | [ ' 0 '-' 9 ' ] + { INT ïŒ int_of_string ïŒ LexingãLexeme lexbuf ïŒ ïŒ }
- | ïŒ "d" | "D" ïŒ ïŒ "a" | "A" ïŒ ïŒ "y" | "Y" ïŒ {äžãã}
- | ïŒ "n" | "H" ïŒ ïŒ "a" | "A" ïŒ {ãã€ã¯}
- | ïŒ "h" | "h" ïŒ ïŒ "o" | "o" ïŒ { WASSUP }
- | ïŒ "th" | "th" ïŒ ïŒ "o" | "O" ïŒ ïŒ "b" | "B" ïŒ ïŒ "a" | "A" ïŒ {ãã}
- | ïŒ "l" | "l" ïŒ ïŒ "y" | "y" ïŒ ïŒ "b" | "b" ïŒ ïŒ "l" | " l " ïŒ ïŒ "y" | " y " ïŒ { RULEZ }
- | ïŒ "e" | "E" ïŒ ïŒ "c" | "C" ïŒ ïŒ "t" | "T" ïŒ ïŒ "b" | "b" ïŒ {å«ã }
- | ïŒ "t" | "T" ïŒ ïŒ "a" | "A" ïŒ ïŒ "d" | "D" ïŒ ïŒ "a" | "A" ïŒ { THEN }
- | ïŒ "and" | "AND" ïŒ ïŒ "l" | "L" ïŒ ïŒ "and" | "AND" ïŒ {ãã®ä» }
- | ïŒ "y" | "y" ïŒ ïŒ "c" | "c" ïŒ ïŒ "e" | "e" ïŒ ïŒ "k" | "k" ïŒ ïŒ "and" | "and" ïŒ { MEMORIZE }
- | ïŒ "e" | "E" ïŒ ïŒ "t" | "T" ïŒ ïŒ "o" | "O" ïŒ { IS }
- | ïŒ "x" | "X" ïŒ ïŒ "y" | "Y" ïŒ ïŒ "y" | "Y" ïŒ ïŒ "n" | "H" ïŒ ïŒ "and" | "AND" ïŒ { CALL }
- |
- ïŒ "a" | "b" | "c" | "g" | "d" | "e" | "e" | "w"
- | ãzã | ããããŠã | ãthã | ããã | ãlã | ãmã | ãnã | ããã
- | ãpã | ãpã | ãsã | ãtã | ãuã | ãfã | x | ãcã
- | ãhã | ãwã | ãuã | ãbã | ãsã | ãbã | ãeã | ãuã | "I" ïŒ + { ID ïŒ Lexingãlexeme lexbuf ïŒ }
- | eof { Eofãäžãã }
ãããã€ãªèšèªã®èªåœã¯ãã¹ãŠããã§èª¬æããŠããããããã®ã³ãŒãã¯åäŸã粟ç¥çµç¹ãè匱ãªäººã«ã¯èŠããŠã¯ãªããªãããšã«æ³šæããŠãã ããã ããã«ãæåã«ããŒãµãŒã®ã¢ãžã¥ãŒã«ãéããŸãããã®ã¢ãžã¥ãŒã«ã§ã¯ããã¹ãŠã®ã¿ã€ãïŒSTATSãGIVEãTAKEãªã©ïŒãå®çŸ©ãããŠãããå ¥åãçµäºãããšãã«ã¹ããŒãããäŸå€ãäœæããŸãã 11è¡ç®ã«æ³šæããŠãã ãããã¹ããŒã¹ããã®ä»ã®ãŽãã¯ç¡èŠããå¿ èŠãããããšã瀺ããŠããŸãããã¹ããŒã¹ãå«ãåœä»€ã®åŸã«ã¯ç¹ã«ç¶ããŸãã 12è¡ç®ãš25-28è¡ç®ã¯å€æ°ã®æ°ãšååãåŠçãã29è¡ç®ã¯ãã¡ã€ã«ã®çµããã瀺ãäŸå€ãã¹ããŒããŸãã
éèš³
æåŸã®éšå-èšèªæ§æãåŠçããã€ã³ã¿ãŒããªã¿ãŒèªäœã æåã«ã³ãŒãã次ã«èª¬æïŒ
- YobaTypeãéã
- let identifiers = Hashtbl ã äœæ 10 ;;
- let funcs = Hashtbl ã äœæ 10 ;;
- let print_stats ïŒ ïŒ =
- let print_item id amount =
- Printf ã printf ">> YoïŒYou haveïŒ sïŒïŒ d" id amount ;
- print_newline ïŒ ïŒ ;
- æšæºåºå ã ãã©ãã·ã¥
- Hashtbl ã iter print_item identifiers ;;
- arithm id opå€ïŒ ïŒ =
- è©ŠããŠã¿ã
- Hashtbl ã èå¥åid ïŒ op ïŒ Hashtbl ãèå¥åidã®æ€çŽ¢ ïŒå€ïŒã 眮ãæããŸãã
- Printf ã printf ">>ãã質å\ n" ; ãã©ãã·ã¥ æšæºåºå
- Not_found- > Printfã§ã printf ">> X @ïŒonãyouïŒ sã¯å«ãã§ã \ n" id ; æšæºåºåã ãã©ãã·ã¥ããŸã ;;
- let cond cond id id act1 act2 ïŒ ïŒ =
- è©ŠããŠã¿ã
- hashtblã®å Žå ã èå¥åãèŠã€ãã id > = amount then process_action act1 ïŒ ïŒ else process_action act2 ïŒ ïŒ
- Not_foundã§->
- Printf ã printf ">>ãªã«ïŒïŒ\ n" ;
- ãã©ãã·ã¥ æšæºåºå
- ããã³ process_action = function
- | Create ïŒ id ïŒ -> ïŒ function ïŒ ïŒ -> HashtblãID 0ã è¿œå ïŒ
- | æžå°ïŒ amountãid ïŒ -> arithm id ïŒ - ïŒ amount
- | ã€ã³ã¯ãªã¡ã³ãïŒ amountãid ïŒ -> arithm id ïŒ + ïŒ amount
- | æ¡ä»¶ä»ãïŒ amountãidãact1ãact2 ïŒ -> cond amount id act1 act2
- | DoNothing -> ïŒ é¢æ° ïŒ ïŒ -> ïŒ ïŒ ïŒ
- | çµ±èš-> print_stats
- | AddFunction ïŒ idãfunclist ïŒ -> ïŒ function ïŒ ïŒ -> Hashtblãfuncs id funclistãè¿œå ïŒ
- | CallFunction ïŒ id ïŒ -> callfun id
- ããã³ callfun id ïŒ ïŒ =
- let f ïŒ YobaType ã ã¢ã¯ã·ã§ã³ãªã¹ã= Hashtbl funcs id ã èŠã€ãã
- äžèŠ§ iter ïŒ é¢æ° x- > process_action x ïŒ ïŒ ïŒ f
- ;;
- æ¬åœ ãªãã
- è©ŠããŠã¿ã
- let lexbuf = Lexing ã from_channel stdin in
- process_action ïŒ YobaParserãmain YobaLexerãtoken lexbuf ïŒ ïŒ ïŒ
- ãš
- YobaLexer ã Eof- >
- print_stats ïŒ ïŒ ;
- åºå£0
- | 解æäžã Parse_error- >
- Printf ã printf ">>ã©ã¡ãã§ããªã@ïŒç解ã§ããªãã£ãb @ïŒïŒ\ n" ;
- ãã©ãã·ã¥ æšæºåºå
- | 倱æïŒ _ ïŒ ->
- Printf ã printf ">>ã©ã¡ãã§ããªã@ïŒç解ã§ããªãã£ãb @ïŒïŒ\ n" ;
- ãã©ãã·ã¥ æšæºåºå
- ãã£ã
ãŸããå€æ°çšãšé¢æ°çšã®2ã€ã®ããã·ã¥ããŒãã«ãäœæããŸãã åæãµã€ãºã®10ã¯æäžé»ç¯ããååŸãããåããã¬ãŒãã³ã°èšèªã䜿çšããŠããŸãããäžåºŠã«å€ãã®æ©èœãå¿ èŠãªã®ã¯ãªãã§ããã
次ã«ã2ã€ã®å°ããªé¢æ°ã宣èšããŸãã1ã€ã¯çµ±èšã®åºåçšããã1ã€ã¯å€æ°ã®ã€ã³ã¯ãªã¡ã³ã/ãã¯ãªã¡ã³ãçšã§ãã
次ã«ã3ã€ã®é¢æ°ã®ã°ã«ãŒããäžåºŠã«æ¥ãŸããcondã¯æ¡ä»¶ä»ãã³ã³ã¹ãã©ã¯ãïŒç§ãã¡ã®ifïŒãåŠçããcallfunã¯é¢æ°ã®åŒã³åºããæ åœããprocess_actionã¯å ¥åãšããŠæ¥ãåœä»€ãåŠçããŸãã 3ã€ã®æ©èœãã¹ãŠãäºãã«äŸåããŠããçç±ã説æããŸãã
process_actionã®ãã¹ãŠã®ãªãã·ã§ã³ã¯ã¢ã¯ã·ã§ã³ãå®è¡ãããåã«å®è¡ããé¢æ°ãè¿ãã ãã§ããããšã«æ³šæããŠãã ããã æåã¯ããã§ã¯ãããŸããã§ãããããã®å°ããªå€æŽã«ããããŠãŒã¶ãŒé¢æ°ã®ãµããŒããèšèªã«ç°¡åãã€ç°¡åã«è¿œå ã§ããŸããã
æåŸã«ãã³ãŒãã®æåŸã®éšåã¯ãã«ãŒãå ã§éã«å€ããåã«ãããŒãµãŒã®çµæãèªã¿åã£ãŠåŠçããŸãã
ããã«Makefileãè¿œå ãããšãåçã§ããŸãïŒ
all:
ocamlc -c yobaType.ml
ocamllex yobaLexer.mll
ocamlyacc yobaParser.mly
ocamlc -c yobaParser.mli
ocamlc -c yobaLexer.ml
ocamlc -c yobaParser.ml
ocamlc -c yoba.ml
ocamlc -o yoba yobaLexer.cmo yobaParser.cmo yoba.cmo
clean:
rm -f *.cmo *.cmi *.mli yoba yobaLexer.ml yobaParser.ml
èšèªãã§ãã¯
ããŠã泚æããªãå€ãšå€æ°ã®ç°ãªãé åºããµããŒãããã®ã§ããïŒ äºå®ã¯ãèšèªãéåžžã«ãã€ãŸãèªç¶ã§ãéèš³ãæåéãããªãã«è©±ããããŠãããšããããšã§ãã ãããã£ãŠãç§èªèº«ã¯äœãæžãã¹ããã«ã€ããŠåžžã«æ··ä¹±ããŠããŸãã
$ ./yoba
3
4
2
@#
>>
>>
>>
>> ! : 7
>> ! : -2
4 1 @#
>>
>> ! : 7
>> ! : -1
4 @# @#
>>
>>
>>
>> ! : 14
>> ! : -3
æ¬ ç¹ã®1ã€ã¯ãé¢æ°ãåŒã³åºããšãã«ãæäœã®æ°ã«ããã€ã³ã¯ãªã¡ã³ã/ãã¯ãªã¡ã³ãã®æåã«é¢ããã³ã¡ã³ããåºãŠããããšã§ãã
é¢çœãã£ããšæããŸãã ãã¹ãŠã®ã€ã³ã¿ãŒããªã¿ãŒã³ãŒãã¯ããããããŠã³ããŒãã§ããŸãïŒ2kbïŒ ã
ããçµéšè±å¯ãªäººã ãã³ãŒãã«ã€ããŠã®ã³ã¡ã³ããå ±æããå Žåãç§ã¯æè¬ããŸãã