//输入一个数(大于10),返回它的n-1位,并输出
unsigned fun(unsigned integ);
void main()
{
int n;
int val;
back:
printf("请输入一个大于10的整数:\n");
scanf("%d",&n);
if(n<10)
{
printf("参数错误,请重新输入!");
goto back;
}
val=fun(n);
printf("该数的n-1位是%d\n",val);
}
unsigned fun(unsigned integ)
{
unsigned int a=1;
int i,j;
unsigned int num=integ;
int res;
for(i=0;num!=0;i++)
{
num=num/10;
}
for(j=1;j<i;j++)
{
a=a*10;
}
res=integ%a;
return res;
}