MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Wednesday, March 6, 2013

uva solve problem 10473

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    char a[1000];
    long long int sum,i,j,h,k,la,t;
    while(scanf("%s",a)!=EOF)
    {
    la=strlen(a);
    t=a[0]-48;
    if(t<0)
    break;
    if(t==0)
    {
        k=2;
        sum=0;
        for(i=la-3;i>=0;i--)
        {
            sum=sum+(a[k]-48)*pow(16,i);
            k++;
        }
       printf("%lld\n",sum);
    }
    else
    {
    sum=0;
    h=0;
     for(j=la-1;j>=0;j--)
     {
     sum=sum+(a[j]-48)*pow(10,h);
     h=h+1;
     }
   printf("0x");
    printf("%x\n",sum);
    }
    }
return 0;
}

No comments:

Post a Comment