Created
February 5, 2015 05:34
-
-
Save shohan4556/5724b20cd15e719f6a28 to your computer and use it in GitHub Desktop.
quora 1593 help
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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("%s",num); | |
| for(i=0;num[i]!='\0';i++){ | |
| t=num[i]-'0'; // my problem is there it | |
| a=binary(t); | |
| printf("%d ",a); | |
| } | |
| printf("\n"); | |
| 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