c++去除一个整数末尾的零,c++去除一个整数末尾的零c++去除一个整数末尾的零
5条回答 默认 最新
- _GX_ 2022-09-10 19:21关注
#include <iostream> int main() { int x; std::cin >> x; while (x != 0 && x % 10 == 0) x /= 10; std::cout << x; return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
#include <iostream>
int main() {
int x;
std::cin >> x;
while (x != 0 && x % 10 == 0)
x /= 10;
std::cout << x;
return 0;
}