{"id":7517,"date":"2009-04-08T16:16:22","date_gmt":"2009-04-08T13:16:22","guid":{"rendered":"http:\/\/studentpmr.ru\/?p=7517"},"modified":"2009-04-08T16:16:22","modified_gmt":"2009-04-08T13:16:22","slug":"%d1%88%d0%b0%d0%b1%d0%bb%d0%be%d0%bd%d0%bd%d1%8b%d0%b5-%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8","status":"publish","type":"post","link":"https:\/\/studentpmr.ru\/?p=7517","title":{"rendered":"\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438"},"content":{"rendered":"<p>\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:<\/p>\n<p>template&lt;classT&gt; void f(T param)<\/p>\n<p>{ \/\/ \u0422\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 }<\/p>\n<p> <!--more-->  <\/p>\n<p>\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 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \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:<\/p>\n<p>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<\/p>\n<p>{ \/\/ \u0422\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 }<\/p>\n<p>\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:<\/p>\n<p>double f(int a, double b);<\/p>\n<p>\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.<\/p>\n<p>\/\/\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 1<\/p>\n<p>#ifndef _MINMAX<\/p>\n<p>#define _MINMAX<\/p>\n<p>template&lt;class T&gt; T max(T a, T b)<\/p>\n<p>{<\/p>\n<p>if( a&gt;b )<\/p>\n<p>return a;<\/p>\n<p>else<\/p>\n<p>return b;<\/p>\n<p>}<\/p>\n<p>template&lt;class T&gt; T min(T a, T b)<\/p>\n<p>{<\/p>\n<p>if( a&lt;b )<\/p>\n<p>return a;<\/p>\n<p>else<\/p>\n<p>return b;<\/p>\n<p>}<\/p>\n<p>#endif<\/p>\n<p>\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.<\/p>\n<p>#include &lt;iostream.h&gt;<\/p>\n<p>#include &lt;conio.h&gt;<\/p>\n<p>#include &quot;minmax.h&quot;<\/p>\n<p>int max (int a, int b);<\/p>\n<p>double max (double a, double b);<\/p>\n<p>char max (char a, char b);<\/p>\n<p>void main()<\/p>\n<p>{<\/p>\n<p>clrscr();<\/p>\n<p>int i1 = 100, i2 = 200;<\/p>\n<p>double d1 = 3.14, d2 = 9.87;<\/p>\n<p>char c1 = &#8216;A&#8217;, c2 = &#8216;z&#8217;;<\/p>\n<p>cout &lt;&lt; &quot;100, 200 \\n&quot;;<\/p>\n<p>cout &lt;&lt; &quot;max(i1, i2) == &quot; &lt;&lt; max(i1, i2) &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; &quot;3.14, 9.87 \\n&quot;;<\/p>\n<p>cout &lt;&lt; &quot;max(d1, d2) == &quot; &lt;&lt; max(d1, d2) &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; c1 &lt;&lt; c2 &lt;&lt; &quot;\\n&quot;;<\/p>\n<p>cout &lt;&lt; &quot;max(c1, c2) == &quot; &lt;&lt; max(c1, c2) &lt;&lt; endl;<\/p>\n<p>}<\/p>\n<p>\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>\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 }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"_links":{"self":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/7517"}],"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=7517"}],"version-history":[{"count":0,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/7517\/revisions"}],"wp:attachment":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}