Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created February 5, 2015 04:28
Show Gist options
  • Select an option

  • Save shohan4556/a78a0b73dc01e8a5ac8e to your computer and use it in GitHub Desktop.

Select an option

Save shohan4556/a78a0b73dc01e8a5ac8e to your computer and use it in GitHub Desktop.
1593
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define N 20000000
char num[N];
int binary(int n);
int main()
{
int n,count,a,i,j,t;
scanf("%d",&n);
while(n--){
scanf("%s",num);
for(i=0;num[i]!='\0';i++){
t=num[i]-'0';
a=binary(t);
printf("%d ",a);
}
printf("\n");
//printf("%d",a);
}
return 0;
}
int binary(int n)
{
int dstinatb=2,numb=10,po=0;
int res=0;
while(n)
{
res=res+n%dstinatb*pow(numb,po++);
n=n/dstinatb;
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment