systemy przeliczen
This commit is contained in:
parent
2ae405b33c
commit
5c08770c7a
40
cpp/dziesietna_na_osemkowa/main.cpp
Normal file
40
cpp/dziesietna_na_osemkowa/main.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <iostream>
|
||||
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;
|
||||
}
|
21
cpp/dziesietna_na_osemkowa/main.py
Normal file
21
cpp/dziesietna_na_osemkowa/main.py
Normal file
@ -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")
|
60
cpp/system10-16/main.cpp
Normal file
60
cpp/system10-16/main.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <iostream>
|
||||
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;
|
||||
}
|
128
cpp/system10-n/main.cpp
Normal file
128
cpp/system10-n/main.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user