Sun Jul 06, 2008 1:47 pm
Mon Jul 07, 2008 5:09 pm
Tue Jul 08, 2008 10:09 am
Tue Jul 15, 2008 5:14 pm
int number = 0;
char numberchars[] = "10011210582553796";
int i = 0;
int ans = 0;
int carry = 0;
char answerArray[100] = {0};
char remainderArray[100] = {0};
int remindex = 0;
int ansindex = 0;
int remainder = 0;
while( numberchars[i] != '\0' )
{
while( numberchars[i] != '\0' )
{
char currentchar[2] = {0};
currentchar[0]=numberchars[i];
int num = atoi(currentchar);
num += remainder;
remainder = 0;
if ( num < 2 )
{
remainder = num;
if(i>0)
answerArray[ansindex++] = '0';
}
else
{
remainder = num % 2;
int answer = num / 2;
char a[2] = {0};
itoa(answer,a,10);
answerArray[ansindex++] = a[0];
}
i++;
remainder *= 10;
}
char a[2] = {0};
int rval = remainder / 10;
itoa(remainder / 10,a,10);
remainderArray[remindex++] = a[0];
int size = sizeof(answerArray);
memcpy(numberchars,answerArray,sizeof(answerArray));
size = sizeof(answerArray);
memset(answerArray,0,sizeof(answerArray));
ansindex = 0;
remainder = 0;
i=0;
}
char int64[8] = {0};
for(int k=0;remainderArray[k]!= '\0';k++)
{
int64[7-(k/8)] |= ((remainderArray[k]-'0') << (k%8));
}
Tue Jul 15, 2008 10:08 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.