Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<ctime>
- #include<cstdlib>
- using namespace std;
- string przekrec(string co){
- string gotowe="";
- int y1=7;
- for(int y=7;y>=0;y--){
- gotowe+=co[y];
- }
- return gotowe;
- }
- string zwrocZera(string co,int ile){
- string no;
- for(int x=0;x<8-ile;x++){
- co+="0";
- }
- return przekrec(co);
- }
- string u2(int a){
- int chw=a,bierz,dl,ktoryRaz=0;
- string u22,kol,kol1;
- do{
- bierz=chw;
- kol="";
- u22="";
- if(ktoryRaz==1){
- bierz=256-chw;
- }
- do{
- if(bierz%2==1) u22+='1'; else u22+='0';
- bierz/=2;
- }while(bierz>=1);
- dl=u22.length();
- u22=zwrocZera(u22,dl);
- kol+=u22;
- if(ktoryRaz==0) kol1+="binarnie: "+kol+"\n";
- else kol1+="u2: "+kol;
- ktoryRaz++;
- }while(ktoryRaz!=2);
- return kol1;
- }
- int main(){
- int podL;
- cout<<"Podaj liczbe: ";cin>>podL;cout<<u2(podL)<<"\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment