{"id":2184,"date":"2009-02-27T16:11:42","date_gmt":"2009-02-27T13:11:42","guid":{"rendered":"http:\/\/studentpmr.ru\/?p=2184"},"modified":"2009-02-27T16:11:42","modified_gmt":"2009-02-27T13:11:42","slug":"%d1%82%d0%b5%d0%bc%d0%b0-6-%d1%88%d0%b0%d0%b1%d0%bb%d0%be%d0%bd%d1%8b-%d1%81%d0%bf%d0%b8%d1%81%d0%ba%d0%b8-2","status":"publish","type":"post","link":"https:\/\/studentpmr.ru\/?p=2184","title":{"rendered":"\u0422\u0435\u043c\u0430 6: \u0428\u0430\u0431\u043b\u043e\u043d\u044b. \u0421\u043f\u0438\u0441\u043a\u0438"},"content":{"rendered":"<p>6.1. \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0442\u0430\u043a \u0438 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<!--more--> \u0428\u0430\u0431\u043b\u043e\u043d\u044b  \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e  \u043f\u043e\u043b\u0435\u0437\u043d\u044b  \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b. \u0418\u043d\u043e\u0433\u0434\u0430  \u0438\u0445 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u0442\u0430\u043a \u043a\u0430\u043a  \u043e\u043d\u0438  \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442  \u043b\u0438\u0448\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u043e \u043d\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.  6.1.1 \u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043e\u0431\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430  \u0444\u0443\u043d\u043a\u0446\u0438\u0439  \u0438  \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435,  \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:  template&lt;classT&gt; void f(T param) { \/\/ \u0422\u0435\u043b\u043e  \u0444\u0443\u043d\u043a\u0446\u0438\u0438  } \u0428\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0439 template&lt;class T&gt;, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u0447\u0442\u043e \u0422 &#8212; \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0438\u043c\u044f \u0442\u0438\u043f\u0430. \u0421\u043b\u043e\u0432\u0430 class \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 \u0421++. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c, \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d  \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0422 \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438  \u0444\u0443\u043d\u043a\u0446\u0438\u0438  \u0434\u0430\u043d\u043d\u044b\u0445  \u0434\u043b\u044f  \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (T param), \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (T*  param) \u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 (T&amp; param). \u0428\u0430\u0431\u043b\u043e\u043d \u043c\u043e\u0436\u0435\u0442  \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c  \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e  \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0422, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:  template&lt;class T&gt; T f(int a, T b) \/\/\u0442\u0438\u043f T \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f  \u043f\u043e\u0437\u0436\u0435 {  \/\/  \u0422\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 }  \u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: double f(int a, double b); \u0415\u0441\u043b\u0438  \u0431\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u0439, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0431\u044b\u043b\u0430 \u0431\u044b \u0435\u0435  \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0422 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 double. \/\/\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 1 #ifndef _MINMAX #define _MINMAX  template&lt;class T&gt; T max(T a, T b) { if( a&gt;b ) return a; else return b;  } template&lt;class T&gt; T min(T a, T b) { if( a&lt;b ) return a; else return b; } #endif \u042d\u0442\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e  \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c  \u0434\u043b\u044f  \u043b\u044e\u0431\u044b\u0445  \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. #include &lt;iostream.h&gt; #include &lt;conio.h&gt; #include &#171;minmax.h&#187;  int max (int a, int b); double max (double a, double b); char max (char a, char b); void main() { clrscr(); int i1 = 100, i2 = 200; double d1 = 3.14, d2 = 9.87; char c1 = &#8216;A&#8217;, c2 = &#8216;z&#8217;; cout &lt;&lt; &#171;100, 200 \\n&#187;; cout &lt;&lt; &#171;max(i1, i2) == &#187; &lt;&lt; max(i1, i2) &lt;&lt; endl; cout &lt;&lt; &#171;3.14, 9.87 \\n&#187;; cout &lt;&lt; &#171;max(d1, d2) == &#187; &lt;&lt; max(d1, d2) &lt;&lt; endl; cout &lt;&lt; c1 &lt;&lt; c2 &lt;&lt; &#171;\\n&#187;; cout &lt;&lt; &#171;max(c1, c2) == &#187; &lt;&lt; max(c1, c2) &lt;&lt; endl; } \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0442\u0440\u0438 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430  \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u0449\u0435\u0442 \u0438\u0445  \u0448\u0430\u0431\u043b\u043e\u043d, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u043e \u0442\u0438\u043f\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0435\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.  \u041d\u0430\u0439\u0434\u044f  \u0442\u0430\u043a\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d, \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0442\u0440\u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 max.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>6.1. \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0442\u0430\u043a \u0438 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"_links":{"self":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/2184"}],"collection":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2184"}],"version-history":[{"count":2,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/2184\/revisions"}],"predecessor-version":[{"id":2186,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/2184\/revisions\/2186"}],"wp:attachment":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}