gpt4 book ai didi

c - 如何删除给定号码的第一位数字?

转载 作者:行者123 更新时间:2023-11-30 21:25:28 26 4
gpt4 key购买 nike

如何使用用户定义的函数删除给定数字的第一位数字(假设函数为 DELTOP)?

例如,

x=DELTOP(1748);

我希望 x 的值为 748

有人能告诉我如何轻松地编写这个函数吗?

最佳答案

C++11 一行代码是

int DELTOP(int x) {
return std::stoi(std::to_string(x).substr(1));
}

关于c - 如何删除给定号码的第一位数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29801449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com