首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C语言的有关问题

2012-06-06 
C语言的问题程序:#include stdio.h#include conio.h#include math.hlong f(long b,int a)main(){in

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,可这程序哪出错了
希望给点作用性的指导,小生在这里谢谢各位了!

[解决办法]
为什么不转成字符串了来处理字符串的截取

热点排行