Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TO DZIAŁA XDDDDDD program z zajęć - wyświetlenie liczby dziesiętnej w postaci binarnej (na tablicy, max. 2^32-1)
- ----------------------------------------------------------------------------------------------------------------
- // ConsoleApplication17.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- void do_binar(unsigned int i, int tab[32]);
- int main()
- {
- unsigned int ibity;
- int nrbitu, iwart, ispr;
- int tab[32];
- cout <<"rozmiar"<< sizeof(unsigned int) << endl;
- cout << "wpisywanie bitow:" << endl;
- cout << "podaj bity jako liczbe calkowita ";
- cin >> ibity;
- do_binar(ibity, tab);
- for (int ii = 31; ii >= 0; ii--)
- {
- cout << " " << tab[ii];
- if (ii % 8 == 0)cout << " ";
- }
- getchar();
- getchar();
- return 0;
- }
- void do_binar(unsigned int i, int tab[32])
- {
- unsigned int ilicz, irob;
- irob = i;
- for (ilicz = 0; ilicz <= 31; ilicz++)
- {
- tab[ilicz] = irob % 2;
- irob /= 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement