Хм... Формально VBJScript не запрещён, но по духу - изя. Учту, когда следующий раз буду устраивать Contest. Вот моё решение поставленной задачи. Да, я несколько упростил себе жизнь - не стал делать проверку на корректность числа ("XCIX" - верная запись для 99, "IC" - нет). code_8348.txt
------------ Дoбавленo:
А вот решение 2й задачи: Add(MainForm,261286,-632,-504) { Left=20 Top=105 Caption="PhoneText" } Add(Edit,11486867,-219,-343) { Left=10 Top=5 Width=185 Enabled=1 } Add(Memo,3440135,-23,-392) { Left=10 Top=30 Width=380 Height=225 ScrollBars=3 ReadOnly=0 } Add(Edit,651326,817,658) { Left=225 Top=5 Width=165 } Add(Button,12877360,-891,-497) { Left=200 Top=5 Width=20 Caption=">>" link(onClick,10753013:doEvent1,[]) } Add(Hub,13413367,754,623) { link(onEvent1,4653462:doWork,[]) link(onEvent2,651326:doText,[(802,636)(802,664)]) } Add(For,3459248,-639,-175) { IncludeEnd=1 link(onEvent,4296373:doRead,[]) link(onStop,3114716:##clear,[(-588,-162)(-588,34)]) link(End,5014009:Value,[(-626,-271)(-388,-271)]) } Add(Hub,15356389,-821,-441) { OutCount=7 link(onEvent1,883911:doLoad,[]) link(onEvent2,5449789:In,[(-759,-428)(-759,-456)]) link(onEvent3,16334326:doRead,[(-650,-421)(-650,-386)]) link(onEvent4,11177164:doRead,[(-661,-414)(-661,-330)]) link(onEvent5,3459248:doFor,[(-714,-407)(-714,-169)]) link(onEvent6,1188821:doWork2,[(-714,-400)(-714,83)]) link(onEvent7,13811653:In,[(-763,-393)(-763,-358)]) } Add(StrList,883911,-590,-469) { FileName="Phone.in" } Add(Memory,5253348,-457,-392) { link(onData,13317756:doEvent1,[(-361,-386)(-361,-449)]) } Add(Memory,5014009,-394,-336) { } Add(ArrayRW,16334326,-576,-392) { Index=Integer(0) link(onRead,5253348:doValue,[]) link(Array,14565126:Var2,[]) } Add(ArrayRW,11177164,-534,-336) { Index=Integer(1) link(onRead,5014009:doValue,[]) link(Array,4772141:Var2,[]) } Add(GetDataEx,14565126,-583,-413) { link(Data,883911:Array,[]) } Add(InfoTip,14610124,-471,-420) { Info=#7:Телефон| Height=67 } Add(InfoTip,1963231,-408,-364) { Info=#13:Длина словаря| Height=67 } Add(IntegerArray,1168404,-149,-224) { IntArray=['a'=2,'b'=2,'c'=2,'d'=3,'e'=3,'f'=3,'g'=4,'h'=4,'i'=1,'j'=1,'k'=5,'l'=5,'m'=6,'n'=6,'o'=0,'p'=7,'q'=0,'r'=7,'s'=7,'t'=8,'u'=8,'v'=8,'w'=9,'x'=9,'y'=9,'z'=0] UseName=0 } Add(ArrayRW,4296373,-485,-175) { link(onRead,13558003:doEvent1,[]) link(Array,4772141:Var3,[(-479,-355)]) link(Index,5913647:GetData,[(-472,-187)(-451,-187)]) } Add(GetDataEx,4772141,-541,-364) { link(Data,14565126:Var3,[(-528,-404)]) } Add(EventFromData,5913647,-457,-231) { link(onEvent,12513622:doOperation,[]) } Add(LineBreakEx,15508692,-107,-350) { Caption="Log" Type=1 link(OnEvent,3440135:doAdd,[(-46,-344)(-46,-386)]) } Add(Math,12513622,-408,-231) { Op2=2 ResultType=0 link(onResult,5913647:doData,[(-364,-225)(-364,-237)(-469,-237)(-469,-225)]) link(Op1,3459248:Position,[(-402,-254)(-544,-254)(-544,-131)(-633,-131)]) } Add(Hub,13558003,-359,-175) { OutCount=5 link(onEvent1,9905420:doValue,[(-294,-169)(-294,-260)]) link(onEvent2,5883764:doLoad,[(-283,-162)(-283,-211)]) link(onEvent3,14650723:doClear,[]) link(onEvent5,13243599:doEnum,[(-283,-141)(-283,-92)]) } Add(LineBreakEx,2128213,292,294) { Caption="Log" } Add(Memory,9905420,-240,-266) { } Add(CharArray,5883764,-240,-217) { link(String,9905420:Value,[]) } Add(ArrayEnum,13243599,-240,-98) { link(onItem,15610682:doRead,[]) link(onEndEnum,6696629:doAdd,[(-188,-85)(-188,-30)(-10,-30)(-10,-64)]) link(Array,5883764:Array,[]) } Add(ArrayRW,15610682,-149,-98) { link(onRead,2654949:doStrCat,[]) link(Array,1168404:Array,[]) } Add(Memory,14650723,-9,-168) { Default=String() } Add(StrCat,2654949,-79,-98) { link(onStrCat,14650723:doValue,[(-28,-92)(-28,-162)]) link(Str1,10490685:Var1,[(-73,-110)]) } Add(StrList,6696629,159,-70) { @Hint=#24:Перекодированный словарь| link(Str,10490685:Var2,[(165,-88)(-3,-88)]) } Add(GetDataEx,10490685,-16,-119) { link(Data,14650723:Value,[]) } Add(GlobalVar,6097192,-198,-406) { Name="Phone" } Add(ArrayEnum,15107863,138,399) { link(onItem,4979771:doEvent1,[]) link(onEndEnum,9436757:In,[(186,412)(186,468)]) link(Array,3935705:Var2,[]) } Add(Trim,14560813,705,623) { Char=" " link(onTrim,13413367:doEvent1,[]) } Add(Hub,13317756,-296,-455) { OutCount=3 link(onEvent1,1782333:doWork,[(-242,-449)(-242,-456)]) link(onEvent2,6097192:doValue,[(-231,-442)(-231,-400)]) link(onEvent3,11486867:doText,[(-242,-435)(-242,-337)]) } Add(LineBreak,7878283,47,308) { Caption="ClrList" link(Out,12543684:doClear,[(101,314)(101,307)]) Primary=[5449789,-777,-770] } Add(Hub,10753013,-828,-497) { OutCount=4 link(onEvent1,5150751:doStart,[]) link(onEvent2,15356389:doEvent1,[(-784,-484)(-784,-460)(-833,-460)(-833,-435)]) link(onEvent4,5150751:doStop,[(-746,-470)(-746,-484)]) } Add(TimeCounter,5150751,-695,-497) { link(onStop,261286:doCaption,[(-647,-484)(-647,-498)]) } Add(StrList,12543684,124,294) { @Hint=#19:Хранилище вариантов| link(Str,3483630:Var3,[(130,212)]) } Add(MultiElementEx,3114716,-569,21) { Mode=1 link(onWord,14656686:doEvent1,[]) link(onNoWord,4069836:doEvent1,[(-516,34)(-516,104)]) link(onDone,3440925:In,[(-529,41)(-529,118)]) link(NewDict,5364651:Var1,[(-563,2)]) link(Pos,1451002:Value,[(-556,-5)(-318,-5)]) } BEGIN_SDK Pos(2,0) Add(EditMultiEx,6097579,19,21) { WorkCount=#5:##add|7:##clear|9:##hdelete| EventCount=#6:onWord|8:onNoWord|6:onDone| VarCount=#13:##eventHandle| DataCount=#7:NewDict|3:Pos| Width=867 Height=564 Point(##add) Point(##clear) Point(##hdelete) Point(##eventHandle) link(##add,12972761:doEvent1,[(47,27)(47,83)]) } Add(GlobalVar,6097192,194,35) { Name="Phone" } Add(ArrayEnum,7396930,33,189) { link(onItem,12905215:doEvent1,[(95,195)(95,132)]) link(onEndEnum,6097579:onNoWord,[(490,202)(490,34)]) link(Array,6097579:NewDict,[(39,105)(25,105)]) } Add(Hub,12905215,124,126) { link(onEvent1,4790727:doLength,[(196,132)(196,195)]) link(onEvent2,15055374:doCompare,[(186,139)(186,258)]) } Add(Copy,9200133,523,371) { link(onCopy,3555780:doValue,[]) link(Str,6820122:Var3,[(529,65)]) link(Position,14855270:Var2,[(536,195)(375,195)]) link(Count,11339734:Var2,[(543,255)(382,255)]) } Add(Length,4790727,236,189) { link(onLength,14249734:doOperation,[]) } Add(If_else,9226192,509,448) { link(onTrue,4570366:doEvent1,[]) link(Op1,3691365:Data,[(515,370)(319,370)]) link(Op2,3555780:Value,[(522,426)(585,426)]) } Add(Memory,3555780,579,371) { } Add(If_else,15055374,215,252) { Type=1 link(onFalse,13727431:doCompare,[]) link(Op1,6372545:Var2,[]) link(Op2,15662603:Var1,[(228,240)]) } Add(Math,14249734,285,189) { ResultType=0 link(Op2,12206950:Var2,[]) } Add(GetDataEx,12206950,285,98) { Angle=3 link(Data,6097579:Pos,[(32,107)]) } Add(Hub,12972761,54,77) { OutCount=3 link(onEvent1,14049275:doLength,[]) link(onEvent2,7396930:doEnum,[(98,90)(98,142)(21,142)(21,195)]) } Add(Length,14049275,159,77) { link(onLength,7842586:doOperation,[]) link(Str,6820122:Var1,[(165,65)]) } Add(GetDataEx,6820122,187,56) { link(Data,6097192:Var,[]) } Add(Hub,339423,425,371) { link(onEvent1,9200133:doCopy,[]) link(onEvent2,9226192:doCompare,[(487,384)(487,454)]) } Add(Math,7219575,719,448) { ResultType=0 link(Op1,14855270:Var3,[(725,128)]) link(Op2,11339734:Var3,[(732,247)]) } Add(GetDataEx,14855270,362,119) { link(Data,12206950:Var3,[(375,107)]) } Add(GetDataEx,11339734,369,238) { link(Data,4790727:Result,[(382,232)(242,232)]) } Add(MT_Add,15261910,719,518) { link(onAdd,2275165:doCompare,[]) link(Data,7219575:Result,[]) } Add(Hub,4570366,572,448) { link(onEvent1,7219575:doOperation,[]) link(onEvent2,1734629:doData,[(620,461)(620,524)]) } Add(If_else,13727431,264,259) { link(onTrue,3691365:doWork1,[]) link(onFalse,3691365:doWork2,[]) link(Op1,15662603:Var2,[]) link(Op2,6372545:Var3,[(277,135)]) } Add(Math,7842586,215,77) { Op2=1 ResultType=0 } Add(GetDataEx,15662603,257,231) { Angle=1 link(Data,14249734:Result,[(291,240)]) } Add(Hub,14446439,362,259) { link(onEvent1,9304417:doValue,[]) link(onEvent2,339423:doEvent1,[(410,272)(410,377)]) } Add(ChanelToIndex,3691365,313,259) { Point(Data) link(onIndex,14446439:doEvent1,[]) } Add(Memory,9304417,474,259) { } Add(If_else,2275165,775,518) { Op2=Integer(1) link(onTrue,6097579:onWord,[(822,524)(822,27)]) link(onFalse,6097579:onDone,[(830,531)(830,41)]) link(Op1,9304417:Value,[(781,432)(480,432)]) } Add(DoData,1734629,635,518) { link(onEventData,15261910:doAdd,[]) link(Data,7396930:Index,[(641,343)(46,343)]) } Add(GetDataEx,6372545,208,126) { link(Data,7842586:Result,[]) } END_SDK Add(Stack,1451002,-324,-63) { Default=Integer(1) IgnorEmpty=1 } Add(Hub,14656686,-506,21) { link(onEvent1,12287210:doWork2,[]) link(onEvent2,1188821:doWork3,[(-466,34)(-466,96)(-635,96)]) } Add(HubEx,1188821,-639,70) { link(onEvent,3114716:##add,[(-600,83)(-600,27)]) } Add(Hub,4069836,-450,98) { OutCount=3 link(onEvent1,1451002:doPop,[(-371,104)(-371,-50)]) link(onEvent2,8086871:doWork2,[(-329,111)(-329,41)]) link(onEvent3,3978614:doData,[(-392,118)(-392,139)]) } Add(HubEx,12287210,-464,14) { link(onEvent,14106977:doGet,[]) } Add(DoData,3978614,-366,133) { link(onEventData,4831041:doValue,[]) link(Data,3114716:##eventHandle,[(-360,88)(-563,88)]) } Add(Thread,16366165,-198,133) { Delay=0 FastStop=0 link(onExec,7368388:doData,[]) } Add(Memory,4831041,-282,133) { link(onData,16366165:doStart,[]) } Add(DoData,7368388,-135,133) { link(onEventData,3114716:##hdelete,[(-91,139)(-91,90)(-581,90)(-581,41)]) link(Data,4831041:Value,[(-129,121)(-213,121)(-213,177)(-276,177)]) } Add(MT_Get,14106977,-443,21) { link(onData,1451002:doPush,[(-355,27)(-355,-57)]) link(onGet,8086871:doWork1,[]) } Add(LineBreak,11285943,-583,217) { Caption="Done" link(Out,311187:doEvent1,[]) Primary=[3440925,63,-105] } Add(Hub,311187,-506,217) { OutCount=3 link(onEvent1,12287210:doWork3,[(-460,223)]) link(onEvent2,14554258:doClear,[(-336,230)(-336,181)]) link(onEvent3,13663161:doEnum,[(-406,237)(-406,244)]) } Add(MultiElement,8086871,-240,28) { @Hint=#7:@Stack@|5:#push|4:#pop| } BEGIN_SDK Add(EditMulti,4269318,21,21) { WorkCount=2 VarCount=1 Width=496 Height=340 link(doWork1,1492520:doAdd,[(115,27)(115,69)]) link(doWork2,278045:doOperation,[(45,34)(45,153)]) link(Var1,1492520:Array,[(27,198)(230,198)]) } Add(StrList,1492520,210,63) { } Add(Math,278045,70,147) { OpType=1 Op2=1 ResultType=0 link(onResult,1492520:doDelete,[(156,153)(156,83)]) link(Op1,1492520:Count,[(76,127)(223,127)]) } END_SDK Add(ArrayEnum,13663161,-338,238) { link(onItem,493253:doEvent1,[]) link(onEndEnum,12543684:doAdd,[(-267,251)(-267,300)]) link(Array,8086871:Var1,[(-332,199)(-234,199)]) } Add(Memory,14554258,61,168) { Default=String() } Add(GetDataEx,3483630,54,203) { link(Data,14554258:Value,[]) } Add(FormatStr,8749986,-30,238) { link(onFString,14554258:doValue,[(53,244)(53,174)]) link(Str1,3483630:Var1,[(-24,212)]) } Add(LineBreak,7897128,-86,399) { Caption="RecursionDone" link(Out,178489:doCompare,[]) Primary=[13811653,-651,-763] } Add(LineBreak,13703579,-639,-301) { Caption="BigDict" Type=1 link(Data,14565126:Var1,[(-633,-404)]) Primary=[530994,511,483] } Add(Hub,493253,-261,238) { link(onEvent1,3504976:doOperation,[]) } Add(Math,3504976,-191,238) { Op2=2 ResultType=0 link(onResult,3313755:doRead,[]) } Add(ArrayRW,3313755,-128,238) { link(onRead,8749986:doString,[]) link(Array,530994:Var,[]) } Add(ArrayRW,10211637,-114,336) { link(Array,5364651:Var2,[(-108,280)(4,280)]) } Add(GetDataEx,5364651,-9,-7) { Angle=1 link(Data,6696629:Array,[(179,2)]) } Add(LineBreakEx,1782333,-219,-462) { Caption="Log" } Add(LineBreakEx,4653462,817,623) { Caption="Log" } Add(Hub,4979771,236,399) { OutCount=5 link(onEvent2,3801085:doClear,[(312,412)(312,321)]) link(onEvent3,9415158:doReset,[(291,419)(291,440)]) link(onEvent4,9415158:doSearch,[(304,426)(304,433)]) link(onEvent5,5692304:doCompare,[(281,433)(281,538)]) } Add(If_else,178489,33,399) { Type=2 Op2=Integer(0) link(onTrue,15107863:doEnum,[]) link(onFalse,3198827:doData,[(81,412)(81,482)]) link(Op1,12543684:Count,[(39,369)(137,369)]) } Add(LineBreakEx,8385267,145,476) { Caption="Log" } Add(DoData,3198827,96,476) { Data=String(NONUMBER) link(onEventData,8385267:doWork,[]) } Add(Math,5773541,390,427) { Op2=1 link(onResult,3801085:doValue,[(452,433)(452,314)]) link(Op1,13149634:Var1,[(396,401)]) } Add(Memory,3801085,481,308) { Default=Integer(0) } Add(Position,9415158,341,427) { Target=" " Point(doReset) link(onSearch,5773541:doOperation,[]) } Add(Memory,13945962,642,308) { Default=Integer(0) } Add(If_else,5692304,467,532) { Type=1 link(onTrue,7666507:doWork3,[(506,538)]) link(onFalse,5955840:doCompare,[]) link(Op1,5735048:Var2,[]) link(Op2,1923287:Var2,[(480,514)(529,514)]) } Add(GetDataEx,13149634,460,392) { Angle=1 link(Data,3801085:Value,[(487,401)]) } Add(If_else,5955840,544,539) { Op2=Integer(0) link(onTrue,5800340:doData,[]) link(Op1,1923287:Var3,[(550,492)]) } Add(GetDataEx,5735048,460,427) { link(Data,13149634:Var2,[]) } Add(GetDataEx,1923287,516,483) { link(Data,13945962:Value,[(529,462)(648,462)]) } Add(DoData,5800340,600,539) { link(onEventData,7666507:doWork1,[(644,545)(644,482)]) link(Data,5735048:Var3,[(606,436)]) } Add(HubEx,7666507,502,469) { Angle=3 link(onEvent,4039062:doEvent1,[(506,398)]) } Add(Memory,10801650,677,399) { } Add(Hub,4039062,551,392) { link(onEvent1,13945962:doValue,[(619,398)(619,314)]) link(onEvent2,5593024:doData,[]) } Add(DoData,5593024,621,399) { link(onEventData,10801650:doValue,[]) link(Data,15107863:Index,[(627,384)(204,384)(204,443)(151,443)]) } Add(LineBreak,13227165,586,623) { Caption="Finish" link(Out,10692049:doRead,[]) Primary=[9436757,-385,-161] } Add(ArrayRW,10692049,656,623) { link(onRead,14560813:doTrim,[]) link(Array,3935705:Var3,[(662,366)]) link(Index,10801650:Value,[(669,527)(683,527)]) } Add(GetDataEx,3935705,131,357) { link(Data,12543684:Array,[]) }
------------ Дoбавленo:
Кто-нить решил 3ю задачу?
|