很经典!
#include<stdio.h>
#include<math.h>
long f(long n,int m);
int main()
{long a[10],b[10];
int i=0;
do
{scanf("%ld\t%ld",&b[i],&a[i]);
i++;
}while((a[i-1]>0)||(b[i-1]>0));
i=0;
do
{printf("%ld\n",a[i]>b[i]? f(a[i],1)-f(b[i]-1,1):f(b[i],1)-f(a[i]-1,1));
i++;
}while((a[i-1]>0)||(b[i-1]>0));
}
long f(long n,int m)
{int i=0,s=0;
long p=n;
while(n!=0)
{if(n%10<m) s=s+n%10*i*(long)pow(10.0,i-1);
if(n%10==m) s=s+n%10*i*(long)pow(10.0,i-1)+p-n*(long)pow(10.0,i)+1;
if(n%10>m) s=s+n%10*i*(long)pow(10.0,i-1)+(long)pow(10.0,i);
n=n/10;
i++;
}
return s;
}
多指点!