题解 | #牛牛的digit#
牛牛的digit
http://www.nowcoder.com/practice/21b49f1f495f4280b8a96c415deaa3c4
思路:将输入的x模上10在除以10,然后依次摘出最后一位数
int main(){
int x = 0;
int i = 0;
scanf("%d %d", &x, &i);
int ret = 0;
int mul = 1;
int each = 0;
while(i){
each = (x % 10) * mul;
mul *= 10;
ret += each;
x /= 10;
i--;
}
printf("%d",ret);
return 0;
}