又改了点,还是budui???????????????
#include <stdio.h>
void intToStr(unsigned int num,char* buf)
{
int i,k = 0;
while(num>0)
{
i = num%10;
num/=10;
buf[k++] = i+48;
}
buf[k] = '\0';
}
int CheckBitNum(unsigned int index,unsigned int* Rad,unsigned int* offSet)
{
unsigned int sum = 10,prevSum = 10,i = 1,rtn = 1,prevI;
while(sum<=index)
{
prevSum = sum;
sum+=9*i;
prevI = i;
i*=10;
rtn++;
}
*offSet = index - prevSum;
if(rtn == (rtn/2)*2)
{
*Rad = prevI+*offSet;
return 1;
}
else
{
*Rad = prevI/10+*offSet/10;
return 0;
}
}
int main()
{
unsigned int index,num,temp,Rad,offSet,rtn;
char buf[50];
while(scanf("%ud",&index) && index)
{
if(index > 9)
{
rtn = CheckBitNum(index,&Rad,&offSet);
num = Rad;
intToStr(num,buf);
if(rtn)
printf("%d%s\n",num,buf);
else
{
temp = offSet%10;
printf("%d%d%s\n",num,temp,buf);
}
}
else
printf("%d\n",index);
}
return 0;
}
马马乎乎