# Help someone translate code from pascal to c #

uses crt,math; var b:array [1..255] of integer; k,a,i,n:integer; p:real; begin clrscr; write('Введите двочное число (цифры через пробел): '); p:=0; k:=0; while not eoln do begin read(b[k]); k:=k+1; end; n:=k; for i:=n-1 downto 0 do begin p:=p+power(2,i)*b[i]; end; writeln('Полученное десятичное число: ',p:8:0); p:=p+1; a:=round(p); writeln('Полученное двоичное число: ',a); i:=0; while a>=1 do begin i:=i+1; b[i]:=a mod 2; a:=a div 2; end; n:=i; writeln; for i:=n downto 1 do write(b[i]); readln; end. The code for task: There are given a positive integer n, integers a0, ..., an such that each ai is zero or one and an ≠ 0. The sequence a0, ..., an defines the binary representation of some integer p = an * 2 ^ n + ... + a1 * 2 + a0. There is need to get a sequence of zeros and ones defining a binary representation: the number p - 1.