diff --git a/cpp/dziesietna_na_osemkowa/main.cpp b/cpp/dziesietna_na_osemkowa/main.cpp new file mode 100644 index 0000000..519439c --- /dev/null +++ b/cpp/dziesietna_na_osemkowa/main.cpp @@ -0,0 +1,40 @@ +#include +using namespace std; + +int main() { + int i,k,n,m; + + cout << "Podaj liczbe dziesietna: "; + cin >> n; + int *a = new int[n]; + + m=n; + + i = 1; + while(m>=1) { + a[i] = m % 8; + cout << a[i] << " "; + m = m / 8; + i++; + } + + k = i - 1; + + cout << endl << "K = " << k << endl; + + for(i = 1; i <= k; i++) { + if(i % 3 == 0) { + cout << " " << a[i]; + } + else { + cout << a[i]; + } + } + + cout << endl; + + delete [] a; + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/cpp/dziesietna_na_osemkowa/main.py b/cpp/dziesietna_na_osemkowa/main.py new file mode 100644 index 0000000..90fe16e --- /dev/null +++ b/cpp/dziesietna_na_osemkowa/main.py @@ -0,0 +1,21 @@ +def main(): + liczba_dziesietna = int(input("Podaj liczbę dziesiętną: ")) + + m = liczba_dziesietna + i = 1 + a = liczba_dziesietna + + while m >= 1: + a[i] = m % 8 + print(a[i], end=" ") + m = m / 8 + i += 1 + + k = i - 1 + + print("\nLiczba w systemie 8-cyfrowym: ", end="") + while k >= 1: + print(a[k], end="") + k += 1 + + print("\n") diff --git a/cpp/system10-16/main.cpp b/cpp/system10-16/main.cpp new file mode 100644 index 0000000..d15af55 --- /dev/null +++ b/cpp/system10-16/main.cpp @@ -0,0 +1,60 @@ +#include +using namespace std; + +int main() { + int i,k,n,m; + + cout << "Podaj liczbe dziesietna: "; + cin >> n; + int *a = new int[n]; + + m=n; + + i = 1; + while(m>=1) { + a[i] = m % 16; + m = m / 16; + i++; + } + + k = i - 1; + + cout << endl; + + for(i = 1; i <= k; i++) { + if(i % 4 == 0) { + cout << " "; + } + if(a[i] > 9) { + if(a[i] == 10) { + cout << "A"; + } + if(a[i] == 11) { + cout << "B"; + } + if(a[i] == 12) { + cout << "C"; + } + if(a[i] == 13) { + cout << "D"; + } + if(a[i] == 14) { + cout << "E"; + } + if(a[i] == 15) { + cout << "F"; + } + } + else { + cout << a[i]; + } + + } + + cout << endl; + + delete [] a; + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/cpp/system10-n/main.cpp b/cpp/system10-n/main.cpp new file mode 100644 index 0000000..aa819d1 --- /dev/null +++ b/cpp/system10-n/main.cpp @@ -0,0 +1,128 @@ +#include + +using namespace std; + +void hex() { + int i,k,n,m; + + cout << "Podaj liczbe dziesietna: "; + cin >> n; + int *a = new int[n]; + + m=n; + + i = 1; + while(m>=1) { + a[i] = m % 16; + m = m / 16; + i++; + } + + k = i - 1; + + cout << endl; + + for(i = 1; i <= k; i++) { + if(i % 4 == 0) { + cout << " "; + } + if(a[i] > 9) { + if(a[i] == 10) { + cout << "A"; + } + if(a[i] == 11) { + cout << "B"; + } + if(a[i] == 12) { + cout << "C"; + } + if(a[i] == 13) { + cout << "D"; + } + if(a[i] == 14) { + cout << "E"; + } + if(a[i] == 15) { + cout << "F"; + } + } + else { + cout << a[i]; + } + + } + + cout << endl; + + delete [] a; +} + +void octal() { + int i,k,n,m; + + cout << "Podaj liczbe dziesietna: "; + cin >> n; + int *a = new int[n]; + + m=n; + + i = 1; + while(m>=1) { + a[i] = m % 8; + cout << a[i] << " "; + m = m / 8; + i++; + } + + k = i - 1; + + cout << endl << "K = " << k << endl; + + for(i = 1; i <= k; i++) { + if(i % 3 == 0) { + cout << " " << a[i]; + } + else { + cout << a[i]; + } + } + + cout << endl; + + delete [] a; +} + +int main() { + char choice; + + cout << "Wybierz system :" << endl; + cout << "1. Binarny" << endl; + cout << "2. Oktalny" << endl; + cout << "3. Decymanalny" << endl; + cout << "4. Hexadecimalny" << endl; + cout << "Podaj swoj wybor: "; + + cin >> choice; + + switch(choice) { + case '1': + cout << "Wybierasz system binarny." << endl; + break; + case '2': + system("cls"); + cout << "Wybierasz system oktalny." << endl; + octal(); + case '3': + cout << "Wybierasz system dziesietny." << endl; + break; + case '4': + system("cls"); + cout << "Wybierasz system szesnastkowy." << endl; + hex(); + default: + break; + } + + system("pause"); + return 0; +} \ No newline at end of file