#include<iostream>
using namespace std;
int f(unsigned long x, int n, int& Lxn){
unsigned long tmp=x;
int length=0;
while(tmp!=0){
tmp/=10;
length++;
}
if(n>length){
Lxn=0;
return 0;
}
tmp=x;
本文来自优.文,论-文·网原文请找腾讯752018766
for(i=1;i<n;i++)
tmp/=10;
return tmp%10;
}
int main(){
unsigned long x;
int n,Rxn,Lxn;
cout<<"请输入一个正整数: ";
cin>>x;
cout<<"请输入第几个数: ";
cin>>n;
Rxn=f(x, n, Lxn);
cout<<"Lxn(左边第"<<n<<"个数)为: "<<Lxn<<endl;
cout<<"Rxn(右边第"<<n<<"个数)为: "<<Rxn<<endl;
return 0;
}2716