日期:2014-05-18  浏览次数:20910 次

C语言的问题
程序:#include "stdio.h"
#include "conio.h"
#include "math.h"

long f(long b,int a);
main()
{ int r;
long e,c;
scanf("%ld%d",&e,&r);
c=f(e,r);
printf("%ld",c);
getch();
}
long f(long b,int a)
{
int c,e=0;
 long d=0;
while(e<a)
{
c=b%10;
b=b/10;
d=d+c*pow(10,e);
e++;
  }
  return d;
  }

这题是输入r,e,从e的右边取r位输出(r<=e,r是位数),例:e=123345,r=3,则输出345,可这程序哪出错了
希望给点作用性的指导,小生在这里谢谢各位了!

------解决方案--------------------
为什么不转成字符串了来处理字符串的截取