#include <iostream>
#include <stdlib.h>
#include <limits>
#include <bitset>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
long bin, dec = 0, rem, num, base = 1;
float a;
float b;
int wybor;
do
{
cout <<"======= Logic Master ======" << endl;
cout <<"Co chcesz zrobic?" << endl;
cout <<"[1] Tabele prawdy dla bramek" << endl;
cout <<"[2] Kalkulator" << endl;
cout <<"[3] Przelicznik <--- ALPHA!" << endl;
cout <<"[4] Koniec" << endl;
cout <<"===== created by Czarek ===" << endl;
cin >> wybor;
cin.clear();
cin.sync();
switch(wybor)
{
case 1:
do
{
cout <<"======= Logic Master ======" << endl;
cout <<"Co chcesz zrobic?" << endl;
cout <<"[1] T. prawdy dla AND" << endl;
cout <<"[2] T. prawdy dla NAND" << endl;
cout <<"[3] T. prawdy dla OR" << endl;
cout <<"[4] T. prawdy dla NOR" << endl;
cout <<"[5] T. prawdy dla EXOR" << endl;
cout <<"[6] T. prawdy dla NOT" << endl;
cout <<"[7] Cofnij" << endl;
cout <<"===== created by Czarek ===" << endl;
cin >> wybor;
cin.clear();
cin.sync();
switch(wybor)
{
case 1:
system("cls");
cout <<"AND" << endl;
cout <<"a | b | y" << endl;
cout <<"0 | 0 | 0" << endl;
cout <<"0 | 1 | 0" << endl;
cout <<"1 | 0 | 0" << endl;
cout <<"1 | 1 | 1" << endl;
break;
case 2:
system("cls");
cout <<"NAND" << endl;
cout <<"a | b | y" << endl;
cout <<"0 | 0 | 1" << endl;
cout <<"0 | 1 | 1" << endl;
cout <<"1 | 0 | 1" << endl;
cout <<"1 | 1 | 0" << endl;
break;
case 3:
system("cls");
cout <<"OR" << endl;
cout <<"a | b | y" << endl;
cout <<"0 | 0 | 0" << endl;
cout <<"0 | 1 | 1" << endl;
cout <<"1 | 0 | 1" << endl;
cout <<"1 | 1 | 1" << endl;
break;
case 4:
system("cls");
cout <<"NOR" << endl;
cout <<"a | b | y" << endl;
cout <<"0 | 0 | 1" << endl;
cout <<"0 | 1 | 0" << endl;
cout <<"1 | 0 | 0" << endl;
cout <<"1 | 1 | 0" << endl;
break;
case 5:
system("cls");
cout <<"EXOR" << endl;
cout <<"a | b | y" << endl;
cout <<"0 | 0 | 0" << endl;
cout <<"0 | 1 | 1" << endl;
cout <<"1 | 0 | 1" << endl;
cout <<"1 | 1 | 0" << endl;
break;
case 6:
system("cls");
cout <<"NOT" << endl;
cout <<"a | y" << endl;
cout <<"0 | 1" << endl;
cout <<"1 | 0" << endl;
break;
default:
system("cls");
cout << "Podaj LICZBE od 1 do 7" << endl;
}
}while(wybor != 7);
break;
case 2:
do
{
cout <<"======= Logic Master ======" << endl;
cout <<"Co chcesz zrobic?" << endl;
cout <<"[1] Dodawanie" << endl;
cout <<"[2] Odejmowanie" << endl;
cout <<"[3] Mnozenie" << endl;
cout <<"[4] Dzielenie" << endl;
cout <<"[5] Potegowanie" << endl;
cout <<"[6] Cofnij" << endl;
cout <<"===== created by Czarek ===" << endl;
cin >> wybor;
cin.clear();
cin.sync();
switch(wybor)
{
case 1:
cout <<"Podaj liczbe a: " << endl;
cin >> a;
cout <<"Podaj liczbe b: " << endl;
cin >> b;
system("cls");
cout << "Wynik to: " << a + b << endl;
cin.clear();
cin.sync();
break;
case 2:
cout <<"Podaj liczbe a: " << endl;
cin >> a;
cout <<"Podaj liczbe b: " << endl;
cin >> b;
system("cls");
cout << "Wynik to: " << a - b << endl;
cin.clear();
cin.sync();
break;
case 3:
cout <<"Podaj liczbe a: " << endl;
cin >> a;
cout <<"Podaj liczbe b: " << endl;
cin >> b;
system("cls");
cout << "Wynik to: " << a * b << endl;
cin.clear();
cin.sync();
break;
case 4:
cout <<"Podaj liczbe a: " << endl;
cin >> a;
cout <<"Podaj liczbe b: " << endl;
cin >> b;
if(b != 0)
{
system("cls");
cout << "Wynik to: " << a / b << endl;
break;
}
else
{
system("cls");
cout << "Nie dziel przez 0!" << endl;
}
break;
case 5:
cout <<"Podaj liczbe a: " << endl;
cin >> a;
system("cls");
cout <<"Wynik to: " << a*a << endl;
cin.clear();
cin.sync();
break;
default:
system("cls");
cout << "Zrobiles cos nie tak ;(" << endl;
cin.clear();
cin.sync();
break;
}
}while(wybor != 6);
case 3:
do
{
cout <<"======= Logic Master ======" << endl;
cout <<"Co chcesz zrobic?" << endl;
cout <<"[1] BIN -> DEC" << endl;
cout <<"[2] DEC -> BIN" << endl;
cout <<"[3] DEC -> HEX" << endl;
cout <<"[4] HEX -> DEC" << endl;
cout <<"[5] BIN -> HEX" << endl;
cout <<"[6] HEX -> BIN" << endl;
cout <<"[7] Cofnij" << endl;
cout <<"===== created by Czarek ===" << endl;
cin >> wybor;
cin.clear();
cin.sync();
switch(wybor)
{
case 1:
cout << "Wprowadz liczbe w systemie binarnym: " << endl;
cin.clear();
cin.sync();
cin >> num;
bin = num;
while (num > 0)
{
rem = num % 10;
dec = dec + rem * base;
base = base * 2;
num = num / 10;
}
system("cls");
cout << bin << "w systemie dziesiatkowym to: " << dec << endl;
break;
case 2:
default:
system("cls");
cout << "Zrobiles cos nie tak!" << endl;
break;
}
}while(wybor != 7);
}
}while(wybor != 4);
return 0;
}