#include <stdio.h>
#include <string.h>
void binary(int n)
{
if (n > 0)
{
binary(n / 2);
}
}
int decimal(char *bin)
{
int y = bin[0] - 48;
int i;
for (i = 1; i <= n; i++)
y = y * 2 + bin[i] - 48;\
return y;
}
int main()
{
start:
printf("1 - konwersja z systemu dziesietnego na dwojkowy;\n");
printf("2 - konwersja z systemu dwojkowego na dziesietny;\n");
printf("3 - zakoncz program;\n");
int menu;
int a,c;
char b[15]="";
int nr = 75065;
scanf_s("%d", &menu);
switch (menu)
{
case 1:
printf("Podaj liczbe w systemie dziesiatkowym:\n");
scanf_s("%d", &a);
if ((a
>= 0) && (a
<= nr
)) { printf("\n %d(10) = ", a
); binary
(a
); printf("(2)"); }
else { printf("Liczba spoza zakresu!\n\n"); goto start
; break; }
case 2:
printf("Podaj liczbe w systemie dwojkowym:\n");
scanf_s("%s", &b);
c = decimal(b);
if ((c
>= 0) && (c
<= nr
)) { printf("\n %s(2) = %d(10)", b
,c
);}
else { printf("Liczba spoza zakresu!\n\n"); goto start
; break; }
case 3:
break;
default:
goto start;
}
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}