题解 | #牛牛逆序输出#
牛牛逆序输出
https://www.nowcoder.com/practice/d981181ce18e4cce945fdf52daf037a1
fn reverse_num(num: i32) -> i32 { let mut reversed = 0; let mut n = num; while n != 0 { reversed = reversed * 10 + n % 10; n /= 10; } reversed } fn main() { let mut num = String::new(); std::io::stdin().read_line(&mut num).unwrap(); let num: i32 = num.trim().parse().unwrap(); let reversed = reverse_num(num); println!("{}", reversed); }