{"id":159,"date":"2012-03-09T09:24:13","date_gmt":"2012-03-09T08:24:13","guid":{"rendered":"http:\/\/csipet.web.elte.hu\/?p=159"},"modified":"2012-03-09T09:24:13","modified_gmt":"2012-03-09T08:24:13","slug":"4-het","status":"publish","type":"post","link":"https:\/\/peter.csonka.hu\/hu\/blog\/2012\/03\/4-het\/","title":{"rendered":"4. h\u00e9t"},"content":{"rendered":"<p><a href=\"https:\/\/docs.google.com\/document\/d\/16CnfKOQI8-2_831HP18KG52ETqqdPmhy3sIzq2vNZXE\/edit\">https:\/\/docs.google.com\/document\/d\/16CnfKOQI8-2_831HP18KG52ETqqdPmhy3sIzq2vNZXE\/edit<\/a><\/p>\n<p>Hanoi torony:<\/p>\n<pre lang=\"c\" line=\"1\">\n#include <iostream>\n\nusing namespace std;\n\ndouble hatvany(const double a, const int n){\n\tif(n==0){\n    \treturn 1;\n\t} else {\n    \treturn a*hatvany(a,n-1);\n\t}\n}\n\n\/\/int i=0;\n\nint fib(const int n){\n\/\/\ti++;\n\tif(n==0){\n    \treturn 0;\n\t} else if(n==1){\n    \treturn 1;\n\t} else {\n    \treturn fib(n-1)+fib(n-2);\n\t}\n\n}\n\nvoid hanoi(const int h, char honnan, char hova, char mivel){\n\tif(n>0){\n    \thanoi(n-1, )\n\t}\n}\n\nint main(){\n\/\/\tcout << hatvany(2,3) << endl;\n\/\/\tcout << fib(10) << endl;\n\/\/\tcout << \"lepesek: \" << i << endl;\n\thanoi(3,'A','C','B'); \/\/ A-r\u00f3l C-re rakjuk B seg\u00edts\u00e9g\u00e9vel\n\treturn 0;\n}\n<\/pre>\n<p>Stuct:<\/p>\n<pre lang=\"c\" line=\"1\">\n#include <iostream>\n#include <vector>\n\nusing namespace std;\n\nstruct Eredmeny{\n\tbool van;\n\tint hol;\n}\n\nEredmeny fel11(const vector<double> hom, const int n){\n\tEredmeny sv;\n\tif(n==-1){\n    \t\/\/ fel11:=(hamis,?) a feladatban\n    \tsv.van = false;\n    \treturn sv;\n\t} else if(hom[n]<-10){\n    \t\/\/ fel11:=(igaz,n)\n    \tsv.van = true;\n    \tsv.hol = n;\n    \treturn sv;\n\t} else {\n    \treturn fel11(hom, n-1);\n\t}\n}\n\nint main()\n{\n\tvector<double> hom;\n\tEredmeny er;\n\n\/\/\tbeolvasas(hom); \/\/ othonra\n\thom.push_back(1);\n\thom.push_back(-11);\n\thom.push_back(5);\n\n\ter = fel11(hom, hom.size()-1);\n\tcout << er.van << er.hol << endl;\n\n\treturn 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/docs.google.com\/document\/d\/16CnfKOQI8-2_831HP18KG52ETqqdPmhy3sIzq2vNZXE\/edit Hanoi torony: #include using namespace std; double hatvany(const double a, const int n){ if(n==0){ return 1; } else { return a*hatvany(a,n-1); } } \/\/int i=0; int fib(const int n){ \/\/ i++; if(n==0){ return 0; } else if(n==1){ return 1; } else { return fib(n-1)+fib(n-2); } } void hanoi(const int h, char honnan, char hova, char mivel){ if(n>0){ hanoi(n-1, ) } } int main(){ \/\/ cout<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63],"tags":[],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-programozasi-alapismeretek-2"],"_links":{"self":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":0,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"wp:attachment":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}