{"id":824,"date":"2008-05-30T02:13:19","date_gmt":"2008-05-30T02:13:19","guid":{"rendered":"http:\/\/6teen.ru\/?p=621"},"modified":"2008-05-30T02:13:19","modified_gmt":"2008-05-30T02:13:19","slug":"7244","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=824","title":{"rendered":"\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e"},"content":{"rendered":"<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e\n\n\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437 10-\u0439 \u0432 16-\u044e:\nLabel1.Caption:=Format('%0:x', [StrToInt(Edit1.Text)]);\n\n**************************************************\n\n\u0438\u0437 \u043b\u044e\u0431\u043e\u0439 \u0432 10-\u043d\u0443\u044e:\n\n\u041a\u043e\u0434:\nfunction from_(s:string;ss:byte):longint;\nvar q:longint;\nbegin\nq:=0;\nfor i:=1 to length(s) do begin\ns[i]:=char(ord(s[i]) or 32);\ncase s[i] of\n'0'..'9': q:=q*ss+byte(s[i])-ord('0');\n'a'..'z': q:=q*ss+byte(s[i])-ord('a')+10;\nend; end;\nfrom_:=q;\nend;\n\n\u0418 \u043e\u0431\u0440\u0430\u0442\u043d\u043e:\n\u041a\u043e\u0434:\n\nfunction to_(q:longint;ss:byte):string;\nvar s:string;\ni:longint;\nbegin\ns:='';\nrepeat\ni:=q-trunc(q\/ss)*ss;\nif i>9 then i:=i+ord('A')-ord('9')-1;\ns:=chr(i+ord('0'))+s;\nq:=trunc(q\/ss);\nuntil q=0;\nto_:=s;\nend;\n\n****************************************************************************************\n\n{ \u0424\u0443\u043d\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0447\u0438\u0441\u043b\u043e Value \u0432 Base-\u0440\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f,\nBase \u0434\u043e\u043b\u0436\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 [1..36] \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f\n10-\u044e \u0446\u0438\u0444\u0440\u0430\u043c\u0438 [0..9] \u0438 26-\u044e \u0431\u0443\u043a\u0432\u0430\u043c\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 ['A'..'Z'] }\nfunction Dec2X(const Value, Base: Cardinal): string;\n\n\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0447\u0438\u0441\u043b\u0443 \u0432 N-\u0440\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435\nfunction GetChar(const N: Cardinal): Char;\nbegin\nif N < 10 then\n\/\/ \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0442 1 \u0434\u043e 10\nResult := Char(N + Ord('0'))\nelse\n\/\/ \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0448\u0435 10, \u043d\u043e \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 36 ([0..9] + ['A'..'Z'])\nResult := Char(N - 10 + Ord('A'));\nend;\n\nvar\nV, R: Cardinal;\nbegin\nResult := '';\n\nif Base <= 1 then\nbegin\n\/\/ \u0447\u0438\u0441\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c ;)\nif Base = 1 then\nbegin\n\/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u044d\u0442\u043e\nSetLength(Result, Value);\nFillChar(Result[1], Value, Ord('0'));\nExit;\nend else\n\/\/ \u0430 \u0432\u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u044b\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\nraise EConvertError.Create('\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 0');\nend else\n\/\/ \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f 10-\u044e \u0446\u0438\u0444\u0440\u0430\u043c\u0438 \u0438 26-\u044e \u0431\u0443\u043a\u0432\u0430\u043c\u0438\n\/\/ \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430\nif Base > 10 + (Ord('Z') + 1) - Ord('A') then\nraise EConvertError.Create('\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0442 1 \u0434\u043e 36');\n\n\/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0432 \u0441\u0442\u043e\u043b\u0431\u0438\u043a\nV := Value;\nrepeat\nR := V mod Base;\nV := V div Base;\nResult := GetChar(R) + Result;\nuntil V < 2; \/\/ 2 - \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u0430\u0437\u0430,\n\/\/ \u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \"V div Base\" \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 1\nif V <> 0 then Result := IntToStr(V) + Result;\nend;\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[364,452],"tags":[1315,1503,1603,981,1781],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/824"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=824"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/824\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}