Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long long int conv(int num[11],int max);
- int main(){
- int num[11],c,i=0,max=0;
- printf("Input numbers 0-9 and letters A-F\n(String length must be less or equal to 10 symbols)\n");
- while((c=getchar())!=EOF){
- if(c>='A' && c<='F'){
- num[i]=c-'A'+10;
- i++;
- }
- if(c>='0' && c<='9') {
- num[i]=c-'0';
- i++;
- }
- max=i;
- }
- if(max>10) printf("Input is too long\n");
- else printf("%lli\n",conv(num,max));
- }
- long long int conv(int num[11],int max){
- int k,j;
- long long int s=0;
- long long int multi[]={1,16,256,4096,65536,1048576,16777216,268435456,4294967296,68719476736,1099511627776};
- for(j=0;j<max;j++){
- s=s+num[j]*multi[max-j-1];
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement