/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ /****************************** Na vstupu je rada celociselnych hodnot. Zakoncovaci hodnotou je hodnota -333. Zjistete, jestli prumer sudych hodnot je vetsi, mensi, nebo roven prumeru lichych */ #include #include using namespace std; int main() { int ss,ps,sl,pl,x; float prs,prl; ss=0;ps=0;sl=0;pl=0; cout << "Zadej 1. hodnotu:"; cin >> x; while (x!=-333) { if (x % 2 == 0) {ss+=x;ps++;} else {sl+=x;pl++;} cout << "Zadej " << ps+pl << ". hodnotu (pro ukonceni zadej -333):"; cin >> x; } if (ps>0) {prs=ss/ps; cout << "prumer sudych je:"; cout << std::fixed << std::setprecision(3) << prs << endl;} if (pl>0) {prl=sl/pl; cout << "prumer lichych je:" << prl;} }