#include #include using namespace std; int main(int argc, char *argv[]) { //valtozok int valasztas; double a,b,c,d; char muvelet; cout << "Valassz:" << endl << endl << "[1.] Szelekcio\n[2.] IDK\n[3.] IDK\n\n"; cin >> valasztas; if ( valasztas == 1 ) { system("CLS"); cout << "\t\tSzelekcio" << endl; cout << endl << endl; //If/Else cout << "Szamologep(if/else): " << endl; cout << "a = "; cin >> a; cout << "b = "; cin >> b; cout << "muvelet: "; cin >> muvelet; //Ha '+' if ( muvelet == '+' ) { c = a + b; cout << "Az eredmeny: " << c << endl; } //Ha '-' if ( muvelet == '-' ) { c = a - b; cout << "Az eredmeny: " << c << endl; } //Ha '*' if ( muvelet == '*' ) { c = a * b; cout << "Az eredmeny: " << c << endl; } // Ha '/' && b == 0 akkor nem vegezheto el az osztas.. /*if ( muvelet == '/' ) { if ( b == 0 ) cout << "0.." << endl; else c = a / b; }*/ if ( muvelet == '/' && b != 0 ) { c = a / b; cout << "Az eredmeny: " << c << endl; } else { cout << "nem muvelet!" << endl; } //Switch/Case cout << endl << endl; cout << "Szamologep(switch/case): " << endl; cout << "a = "; cin >> a; cout << "b = "; cin >> b; cout << "muvelet: "; cin >> muvelet; switch(muvelet) { // ide azt a valtozot irjuk amit vizsgalni szeretnenk case '+': //Ha + 'ilyenek koze kell rakni' most nem indoklom c = a + b; cout << "Az eredmeny: " << c << endl; break; // Ez a legfontosabb ha ezt elhagyod akkor tovabbugrik a kivonasra es elvan baszva minden case '-': c = a - b; cout << "Az eredmeny: " << c << endl; break; case '*': c = a * b; cout << "Az eredmeny: " << c << endl; break; case '/': if ( b != 0 ) { c = a + b; cout << "Az eredmeny: " << c << endl; } else cout << "0..." << endl; break; default: cout << "nem muvelet.." << endl; // Ez a default ide akkor jon a prog ha az elozo cuccok nem teljesulnek break; // itt mar felesleges a break; de sose art 6char :D } } cout << endl; system("PAUSE"); return EXIT_SUCCESS; }