{"id":150,"date":"2012-02-24T13:30:47","date_gmt":"2012-02-24T12:30:47","guid":{"rendered":"http:\/\/csipet.web.elte.hu\/?p=150"},"modified":"2012-02-24T13:30:47","modified_gmt":"2012-02-24T12:30:47","slug":"2-het","status":"publish","type":"post","link":"https:\/\/peter.csonka.hu\/hu\/blog\/2012\/02\/2-het\/","title":{"rendered":"2. h\u00e9t"},"content":{"rendered":"<p><a href=\"https:\/\/docs.google.com\/document\/d\/1H8-kF2jE0MuSrao__M93YroymuTdUKxdNlAeak5MHOk\/edit\">https:\/\/docs.google.com\/document\/d\/1H8-kF2jE0MuSrao__M93YroymuTdUKxdNlAeak5MHOk\/edit<\/a><\/p>\n<pre lang=\"c\" line=\"1\">\n#include <iostream>\n#include <fstream>\n#include <vector>\n\nusing namespace std;\n\nvoid beolvasas(vector<double> &x);\nvoid beolvasas_file(vector<double> &x);\nvoid fel1(const vector<double> hom, double &atlag);\nvoid fel3(const vector<double> hom, int &leghidegebbnap);\nvoid fel7(const vector<double> hom, bool &van, int &ind);\nvoid ellkiiras(const vector<double> &hom);\n\nint main()\n{\n    \/\/double hom[MAXN];\n    vector<double> hom;\n\n    \/\/beolvasas(hom);\n    beolvasas_file(hom);\n    ellkiiras(hom);\n\n    double atlag;\n    fel1(hom, atlag);\n    cout << \"Atlaghom= \" << atlag << endl;\n\n    int leghidegebbnap;\n    fel3(hom, leghidegebbnap);\n    cout << \"Leghidegebbnap= \" << leghidegebbnap << endl;\n\n    bool van;\n    int ind;\n    fel7(hom, van, ind);\n    if (van)\n    {\n        cout << \"= a szomszedjaval: \" << ind << endl;\n    }\n    else\n    {\n        cout << \"Nincs = a szomszedjaval\" << endl;\n    }\n\n    return 0;\n}\n\nvoid beolvasas(vector<double> &x)\n{\n    int n;\n    cout << \"n=\";\n    cin >> n;\n    x.resize(n);\n    for (int i=0; i<n; ++i)\n    {\n        cout << i << \". hom: \";\n        cin >> x[i];\n    }\n}\n\nvoid beolvasas_file(vector<double> &x)\n{\n    double sv;\n    \/\/ifstream f(\"be.txt\");\n    ifstream f;\n    string fajlnev;\n    bool hiba;\n\n    do\n    {\n        cout << \"Fajlnev: \";\n        cin >> fajlnev;\n        f.open(fajlnev.c_str());\n        hiba=f.fail();\n        if (hiba)\n        {\n            cout << \"Nem jo fajlnev\" << endl;\n        }\n    }\n    while(hiba);\n\n    \/*while (!f.eof())\n    {\n        f >> sv;\n        if (f.good())\n        {\n            x.push_back(sv);\n        }\n    }*\/\n\n    f >> sv;\n    while (!f.eof())\n    {\n        x.push_back(sv);\n        f >> sv;\n    }\n\n    f.close();\n}\n\nvoid ellkiiras(const vector<double> &hom)\n{\n    for (int i=0; i<hom.size(); ++i)\n    {\n        cout << i << \".: \" << hom[i] << endl;\n    }\n}\n\nvoid fel1(const vector<double> hom, double &atlag)\n{\n    double s=0;\n    int n=hom.size();\n    for (int i=0; i<n; ++i)\n    {\n        s+=hom[i];\n    }\n    atlag=s\/n;\n}\n\nvoid fel3(const vector<double> hom, int &leghidegebbnap)\n{\n    double max=hom[0];\n    leghidegebbnap=0;\n    for (int i=0; i<hom.size(); ++i)\n    {\n        if (hom[i]<max)\n        {\n            leghidegebbnap=i;\n            max=hom[i];\n        }\n    }\n}\n\nvoid fel7(const vector<double> hom, bool &van, int &ind)\n{\n    ind=0;\n    while (ind<hom.size() &#038;&#038; hom[ind]!=hom[ind+1])\n    {\n        ++ind;\n    }\n    van=ind<hom.size();\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/docs.google.com\/document\/d\/1H8-kF2jE0MuSrao__M93YroymuTdUKxdNlAeak5MHOk\/edit #include #include #include using namespace std; void beolvasas(vector &#038;x); void beolvasas_file(vector &#038;x); void fel1(const vector hom, double &#038;atlag); void fel3(const vector hom, int &#038;leghidegebbnap); void fel7(const vector hom, bool &#038;van, int &#038;ind); void ellkiiras(const vector &#038;hom); int main() { \/\/double hom[MAXN]; vector hom; \/\/beolvasas(hom); beolvasas_file(hom); ellkiiras(hom); double atlag; fel1(hom, atlag); 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-150","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\/150","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=150"}],"version-history":[{"count":0,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}