Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int n = 0;
- int tab[8];
- cout << "Podaj liczbe: ";
- cin >> n;
- int i = 0;
- do {
- if (n % 2 == 0) {
- tab[i] = 0;
- i++;
- n = n / 2;
- }
- if (n % 2 == 1) {
- tab[i] = 1;
- i++;
- n = n / 2;
- }
- } while (n != 0);
- int k = i;
- for (int j = k-1; j >= 0; j--) {
- cout <<" "<< tab[j];
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement