{"id":603,"date":"2010-10-28T22:31:46","date_gmt":"2010-10-28T21:31:46","guid":{"rendered":"http:\/\/www.venco.com.pl\/~cozy\/blog\/?p=603"},"modified":"2010-10-28T22:31:46","modified_gmt":"2010-10-28T21:31:46","slug":"najmniejsza-wspolna-wielokrotnoscnajwiekszy-wspolny-dzielnik","status":"publish","type":"post","link":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/2010\/10\/28\/najmniejsza-wspolna-wielokrotnoscnajwiekszy-wspolny-dzielnik\/","title":{"rendered":"Najmniejsza Wsp\u00f3lna Wielokrotno\u015b\u0107\/Najwi\u0119kszy wsp\u00f3lny dzielnik"},"content":{"rendered":"<p><a href=\"http:\/\/www.venco.com.pl\/~cozy\/blog\/wp-content\/uploads\/2010\/10\/nwd.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-771\" title=\"nwd\" src=\"http:\/\/www.venco.com.pl\/~cozy\/blog\/wp-content\/uploads\/2010\/10\/nwd.gif\" alt=\"\" width=\"380\" height=\"300\" srcset=\"http:\/\/u239160.webh.me\/jakisproblem.pl\/wp-content\/uploads\/2010\/10\/nwd.gif 380w, http:\/\/u239160.webh.me\/jakisproblem.pl\/wp-content\/uploads\/2010\/10\/nwd-300x236.gif 300w\" sizes=\"auto, (max-width: 380px) 100vw, 380px\" \/><\/a><!--more--><\/p>\n<p>W C++<\/p>\n<p>#include &lt;iostream&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>\/\/ Funkcja NWD oblicza NWD swoich argument\u00f3w<br \/>\n\/\/ wykorzystuj\u0105c algorytm Euklidesa<br \/>\n\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>unsigned NWD(unsigned a, unsigned b)<br \/>\n{<br \/>\nwhile(a != b) if(a &gt; b) a -= b; else b -= a;<br \/>\nreturn(a);<br \/>\n}<\/p>\n<p>main()<br \/>\n{<br \/>\nunsigned a,b;<br \/>\nchar s[1];<\/p>\n<p>cout &lt;&lt; &#8222;Obliczanie\u00a0 NWD\u00a0 algorytmem\u00a0 Euklidesa\\n&#8221;<br \/>\n&#8222;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\\n&#8221;<br \/>\n&#8222;Podaj a = &#8222;;<br \/>\ncin\u00a0 &gt;&gt; a;<br \/>\ncout &lt;&lt; &#8222;\\nPodaj b = &#8222;;<br \/>\ncin\u00a0 &gt;&gt; b;<br \/>\ncout &lt;&lt; endl;<br \/>\nif((a &lt;= 0) || (b &lt;= 0))<br \/>\ncout &lt;&lt; &#8222;Zle dane!\\n&#8221;;<br \/>\nelse<br \/>\ncout &lt;&lt; &#8222;NWD(&#8221; &lt;&lt; a &lt;&lt; &#8222;,&#8221; &lt;&lt; b &lt;&lt; &#8222;) = &#8221; &lt;&lt; NWD(a,b);<br \/>\n}<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>W Javie<\/p>\n<p>import java.io.BufferedReader;<br \/>\nimport java.io.IOException;<br \/>\nimport java.io.InputStreamReader;<\/p>\n<p>public class nwd {<\/p>\n<p>public static int nwd(int a, int b) {<\/p>\n<p>while (a != b ) {<br \/>\nif (a &gt; b)<br \/>\na = a-b;<br \/>\nelse<br \/>\nb = b-a;<\/p>\n<p>}<\/p>\n<p>return a;<br \/>\n}<\/p>\n<p>public static void main(String[] args){<\/p>\n<p>int a = 0;<br \/>\nint b = 0;<\/p>\n<p>String s;<\/p>\n<p>BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));<\/p>\n<p>System.out.print (&#8222;Podaj a:&#8221;);<br \/>\ntry<br \/>\n{<br \/>\ns = stdin.readLine();<br \/>\na = Math.abs(Integer.parseInt(s));<br \/>\n}<br \/>\ncatch(IOException ioex)<br \/>\n{<br \/>\nSystem.out.println(&#8222;Input error&#8221;);<br \/>\nSystem.exit(1);<br \/>\n}<br \/>\ncatch ( NumberFormatException e)<br \/>\n{<br \/>\nSystem.out.println (e.getMessage() + &#8221; nie jest poprawn\u0105 liczb\u0105 ca\u0142kowit\u0105.&#8221;);<br \/>\nSystem.exit(1);<br \/>\n}<\/p>\n<p>System.out.print (&#8222;Podaj b:&#8221;);<br \/>\ntry<br \/>\n{<br \/>\ns = stdin.readLine();<br \/>\nb = Math.abs(Integer.parseInt(s));<br \/>\n}<br \/>\ncatch(IOException ioex)<br \/>\n{<br \/>\nSystem.out.println(&#8222;Input error&#8221;);<br \/>\nSystem.exit(1);<br \/>\n}<br \/>\ncatch ( NumberFormatException e)<br \/>\n{<br \/>\nSystem.out.println (e.getMessage() + &#8221; nie jest poprawn\u0105 liczb\u0105 ca\u0142kowit\u0105.&#8221;);<br \/>\nSystem.exit(1);<br \/>\n}<\/p>\n<p>if (a == 0 || b == 0)<\/p>\n<p>System.out.println (&#8222;Nie dziel przez zero, cholero&#8221;);<\/p>\n<p>else<\/p>\n<p>System.out.println (&#8222;Najwi\u0119kszy wsp\u00f3lny dzielnik liczb &#8221; + a + &#8221; i &#8221; + b +&#8221; wynosi &#8221; + nwd(a,b));<br \/>\n}<\/p>\n<p>}<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p><img decoding=\"async\" src=\"file:\/\/\/c:\/temp\/moz-screenshot-3.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"file:\/\/\/c:\/temp\/moz-screenshot.png\" alt=\"\" \/><a href=\"http:\/\/www.venco.com.pl\/~cozy\/blog\/wp-content\/uploads\/2010\/10\/1350.gif\"><img decoding=\"async\" src=\"file:\/\/\/c:\/temp\/moz-screenshot-1.png\" alt=\"\" \/><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-604\" title=\"1350\" src=\"http:\/\/www.venco.com.pl\/~cozy\/blog\/wp-content\/uploads\/2010\/10\/1350.gif\" alt=\"\" width=\"719\" height=\"956\" srcset=\"http:\/\/u239160.webh.me\/jakisproblem.pl\/wp-content\/uploads\/2010\/10\/1350.gif 719w, http:\/\/u239160.webh.me\/jakisproblem.pl\/wp-content\/uploads\/2010\/10\/1350-225x300.gif 225w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.venco.com.pl\/~cozy\/blog\/wp-content\/uploads\/2010\/10\/1350.gif\"><\/a>\u017ar\u00f3d\u0142o: http:\/\/matematyka.pisz.pl\/strona\/1350.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/2010\/10\/28\/najmniejsza-wspolna-wielokrotnoscnajwiekszy-wspolny-dzielnik\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[23,25,11,17,9],"class_list":["post-603","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","tag-c","tag-java","tag-matematyka","tag-programowanie","tag-rozne"],"_links":{"self":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/posts\/603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":0,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"wp:attachment":[{"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/u239160.webh.me\/jakisproblem.pl\/index.php\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}