#include <cstdlib>
#include <iostream>
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;
}
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}