Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void f(int x)
- {
- int tab[31],i=0;
- while(x)
- {
- tab[i]=x%2;//wpisuje 0 albo 1 do tablicy
- x=x/2;//dzieli przez 2
- i++;
- }
- for(int j=i-1; j>=0; j--)
- {
- cout<<tab[j];
- }
- }
- int main()
- {
- cout<<"Program pobiera liczbe calkowita dziesaitkowa i podaje jej postac dwujkowo"<<endl;
- cout<<"Podaj liczbe calkowita"<<endl;
- int liczba;
- cin>>liczba;
- f(liczba);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment