{"id":2868,"date":"2019-11-10T22:00:20","date_gmt":"2019-11-10T21:00:20","guid":{"rendered":"http:\/\/www.webotlet.hu\/?p=2868"},"modified":"2019-11-10T22:00:26","modified_gmt":"2019-11-10T21:00:26","slug":"c-programozas-2007-oktoberi-emelt-informatika-erettsegi-lift","status":"publish","type":"post","link":"https:\/\/www.webotlet.hu\/?p=2868","title":{"rendered":"C++ programoz\u00e1s \u2013 2007 okt\u00f3beri emelt informatika \u00e9retts\u00e9gi \u2013 Foci"},"content":{"rendered":"<p>A feladat le\u00edr\u00e1s\u00e1t, melynek a megold\u00e1s\u00e1t k\u00f6zz\u00e9teszem, <a href=\"http:\/\/www.webotlet.hu\/wp-content\/uploads\/2019\/11\/e_info_07okt_foci.pdf\">innen<\/a> t\u00f6ltheted le.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;iostream&gt;\r\n#include &lt;fstream&gt;\r\n#include &lt;sstream&gt;\r\n\r\nusing namespace std;\r\n\r\nstruct meccs\r\n{\r\n    int fordulo;\r\n    int hgol;\r\n    int vgol;\r\n    int hfgol;\r\n    int vfgol;\r\n    string hazai;\r\n    string vendeg;\r\n\r\n    string eredmeny()\r\n    {\r\n        stringstream ss;\r\n        if( hgol &gt; vgol )\r\n        {\r\n            ss &lt;&lt; hgol &lt;&lt; &quot;-&quot; &lt;&lt; vgol;\r\n        }\r\n        else\r\n        {\r\n            ss &lt;&lt; vgol &lt;&lt; &quot;-&quot; &lt;&lt; hgol;\r\n        }\r\n        return ss.str();\r\n    }\r\n\r\n    bool hazai_kikapott()\r\n    {\r\n        return vgol &gt; hgol;\r\n    }\r\n\r\n    string forditott()\r\n    {\r\n        if( hgol &gt; vgol &amp;&amp; hfgol &lt; vfgol )\r\n        {\r\n            return hazai;\r\n        }\r\n        else if( vgol &gt; hgol &amp;&amp; vfgol &lt; hfgol )\r\n        {\r\n            return vendeg;\r\n        }\r\n        else\r\n        {\r\n            return &quot;-&quot;;\r\n        }\r\n    }\r\n\r\n    string toString()\r\n    {\r\n        stringstream ss;\r\n        ss &lt;&lt; fordulo &lt;&lt; &quot; &quot; &lt;&lt; hgol &lt;&lt; &quot; &quot; &lt;&lt; vgol &lt;&lt;\r\n           &quot; &quot; &lt;&lt; hfgol &lt;&lt; &quot; &quot; &lt;&lt; vfgol &lt;&lt; &quot; &quot; &lt;&lt;\r\n           hazai &lt;&lt; &quot; &quot; &lt;&lt; vendeg &lt;&lt; endl;\r\n        return ss.str();\r\n    }\r\n};\r\n\r\nint main()\r\n{\r\n    \/\/ 1. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;1. feladat&quot; &lt;&lt; endl;\r\n    ifstream input(&quot;meccs.txt&quot;);\r\n    int meret;\r\n    input &gt;&gt; meret;\r\n    meccs meccsek&#x5B;meret];\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        input &gt;&gt; meccsek&#x5B;i].fordulo &gt;&gt; meccsek&#x5B;i].hgol &gt;&gt;\r\n                 meccsek&#x5B;i].vgol &gt;&gt; meccsek&#x5B;i].hfgol &gt;&gt;\r\n                 meccsek&#x5B;i].vfgol &gt;&gt; meccsek&#x5B;i].hazai &gt;&gt;\r\n                 meccsek&#x5B;i].vendeg;\r\n\r\n        cout &lt;&lt; meccsek&#x5B;i].toString();\r\n    }\r\n    input.close();\r\n\r\n    \/\/ 2. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;2. feladat&quot; &lt;&lt; endl;\r\n    int fordulo;\r\n    cout &lt;&lt; &quot;Adja meg a fordulo szamat: &quot;;\r\n    cin &gt;&gt; fordulo;\r\n\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        if( meccsek&#x5B;i].fordulo == fordulo )\r\n        {\r\n            cout &lt;&lt; meccsek&#x5B;i].hazai &lt;&lt; &quot;-&quot; &lt;&lt;\r\n                    meccsek&#x5B;i].vendeg &lt;&lt; &quot;: &quot; &lt;&lt;\r\n                    meccsek&#x5B;i].hgol &lt;&lt; &quot;-&quot; &lt;&lt;\r\n                    meccsek&#x5B;i].vgol &lt;&lt; &quot; (&quot; &lt;&lt;\r\n                    meccsek&#x5B;i].hfgol &lt;&lt; &quot;-&quot; &lt;&lt;\r\n                    meccsek&#x5B;i].vfgol &lt;&lt; &quot;)&quot; &lt;&lt; endl;\r\n        }\r\n    }\r\n\r\n    \/\/ 3. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;3. feladat&quot; &lt;&lt; endl;\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        if( meccsek&#x5B;i].forditott() != &quot;-&quot; )\r\n        {\r\n            cout &lt;&lt; meccsek&#x5B;i].fordulo &lt;&lt; &quot; &quot; &lt;&lt;\r\n                 meccsek&#x5B;i].forditott() &lt;&lt; endl;\r\n        }\r\n    }\r\n\r\n    \/\/ 4. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;4. feladat&quot; &lt;&lt; endl;\r\n    string csapat;\r\n    cout &lt;&lt; &quot;Adjon meg egy csapatnevet: &quot;;\r\n    cin &gt;&gt; csapat;\r\n\r\n    \/\/ 5. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;5. feladat&quot; &lt;&lt; endl;\r\n    int lott = 0;\r\n    int kapott = 0;\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        if( meccsek&#x5B;i].hazai == csapat )\r\n        {\r\n            lott += meccsek&#x5B;i].hgol;\r\n            kapott += meccsek&#x5B;i].vgol;\r\n        }\r\n        else if( meccsek&#x5B;i].vendeg == csapat )\r\n        {\r\n            lott += meccsek&#x5B;i].vgol;\r\n            kapott += meccsek&#x5B;i].hgol;\r\n        }\r\n    }\r\n\r\n    cout &lt;&lt; &quot;lott: &quot; &lt;&lt; lott &lt;&lt; &quot; kapott: &quot; &lt;&lt; kapott &lt;&lt; endl;\r\n\r\n    \/\/ 6. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;6. feladat&quot; &lt;&lt; endl;\r\n\r\n    \/\/ 1. megoldas\r\n    \/\/ kivalogatjuk azokat a meccseket,\r\n    \/\/ ahol a hazai csapat kikapott\r\n    int db = 0;\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        if( meccsek&#x5B;i].hazai == csapat &amp;&amp;\r\n            meccsek&#x5B;i].hazai_kikapott() )\r\n        {\r\n            db++;\r\n        }\r\n    }\r\n    meccs hazaikikapott&#x5B;db];\r\n    db = 0;\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        if( meccsek&#x5B;i].hazai == csapat &amp;&amp;\r\n            meccsek&#x5B;i].hazai_kikapott() )\r\n        {\r\n            hazaikikapott&#x5B;db] = meccsek&#x5B;i];\r\n            db++;\r\n        }\r\n    }\r\n\r\n\/\/ megnezzuk, hogy a 21 fordulotol van-e kisebb\r\n\/\/ (21-es fordulo nem letezhet, tehat ha van kisebb,\r\n\/\/ akkor kikapott otthon)\r\n    int min = 21;\r\n    for( int i = 0; i &lt; db; i++ )\r\n    {\r\n        if( hazaikikapott&#x5B;i].fordulo &lt; min )\r\n        {\r\n            min = hazaikikapott&#x5B;i].fordulo;\r\n        }\r\n    }\r\n\r\n    if( min == 21 )\r\n    {\r\n        cout &lt;&lt; &quot;A csapat otthon veretlen maradt.&quot; &lt;&lt; endl;\r\n    }\r\n    else\r\n    {\r\n        cout &lt;&lt; &quot;A csapat eloszor a &quot; &lt;&lt; min &lt;&lt;\r\n        &quot; forduloban kapott ki eloszor otthon.&quot; &lt;&lt; endl;\r\n    }\r\n\r\n\r\n    \/\/ 2. megoldas\r\n    \/\/ 21-es fordulo nincs, igy ha attol kisebbet talalunk,\r\n    \/\/ akkor kikapott\r\n    int fordulomin = 21;\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        if( meccsek&#x5B;i].hazai == csapat &amp;&amp;\r\n            meccsek&#x5B;i].hazai_kikapott() &amp;&amp;\r\n            meccsek&#x5B;i].fordulo &lt; fordulomin )\r\n        {\r\n            fordulomin = meccsek&#x5B;i].fordulo;\r\n        }\r\n    }\r\n\r\n    if( fordulomin == 21 )\r\n    {\r\n        cout &lt;&lt; &quot;A csapat otthon veretlen maradt.&quot; &lt;&lt; endl;\r\n    }\r\n    else\r\n    {\r\n        cout &lt;&lt; &quot;A csapat eloszor a &quot; &lt;&lt; fordulomin &lt;&lt;\r\n        &quot; forduloban kapott ki eloszor otthon.&quot; &lt;&lt; endl;\r\n    }\r\n\r\n\r\n    \/\/ 7. feladat\r\n    cout &lt;&lt; endl &lt;&lt; &quot;7. feladat&quot; &lt;&lt; endl;\r\n    string eredmenyek&#x5B;100];\r\n    int erdarab&#x5B;100] = {0};\r\n\r\n    db = 0;\r\n    for( int i = 0; i &lt; meret; i++ )\r\n    {\r\n        int hely = 0;\r\n        while( hely &lt; db &amp;&amp;\r\n               eredmenyek&#x5B;hely] != meccsek&#x5B;i].eredmeny() )\r\n        {\r\n            hely++;\r\n        }\r\n\r\n        if( hely == db )\r\n        {\r\n            eredmenyek&#x5B;db] = meccsek&#x5B;i].eredmeny();\r\n            db++;\r\n        }\r\n        erdarab&#x5B;hely]++;\r\n    }\r\n\r\n    \/\/ nem feladat, de az eredmenyeket meg az eredmeny\r\n    \/\/ tipusa szerint sorba is lehetne rendezni\r\n\r\n    for( int i = 0; i &lt; db-1; i++ )\r\n    {\r\n        for( int j = i+1; j &lt; db; j++ )\r\n        {\r\n            if( eredmenyek&#x5B;i] &gt; eredmenyek&#x5B;j] )\r\n            {\r\n                swap(eredmenyek&#x5B;i], eredmenyek&#x5B;j] );\r\n                swap(erdarab&#x5B;i], erdarab&#x5B;j] );\r\n            }\r\n        }\r\n    }\r\n\r\n    ofstream output(&quot;stat.txt&quot;);\r\n\r\n    for( int i = 0; i &lt; db; i++ )\r\n    {\r\n        output &lt;&lt; eredmenyek&#x5B;i] &lt;&lt; &quot;: &quot; &lt;&lt; erdarab&#x5B;i] &lt;&lt;\r\n               &quot; darab&quot; &lt;&lt; endl;\r\n    }\r\n\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A feladat le\u00edr\u00e1s\u00e1t, melynek a megold\u00e1s\u00e1t k\u00f6zz\u00e9teszem, innen t\u00f6ltheted le. #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;sstream&gt; using namespace std; struct meccs { int fordulo; int hgol; int vgol; int hfgol; int vfgol; string hazai; string vendeg; string eredmeny() { stringstream <a class=\"more-link\" href=\"https:\/\/www.webotlet.hu\/?p=2868\">Tov\u00e1bb <span class=\"screen-reader-text\">  C++ programoz\u00e1s \u2013 2007 okt\u00f3beri emelt informatika \u00e9retts\u00e9gi \u2013 Foci<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[158,189,159,107,109],"class_list":["post-2868","post","type-post","status-publish","format-standard","hentry","category-c-emelt-erettsegi-feladatok","tag-c","tag-c-feladat","tag-c-programozas","tag-emelt-erettsegi","tag-emelt-informatika-erettsegi"],"_links":{"self":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts\/2868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2868"}],"version-history":[{"count":3,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts\/2868\/revisions"}],"predecessor-version":[{"id":3071,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=\/wp\/v2\/posts\/2868\/revisions\/3071"}],"wp:attachment":[{"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webotlet.hu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}