这样去掉反转后末尾0的代码怎么该对
查看原帖
这样去掉反转后末尾0的代码怎么该对
529247
BLX32M_10楼主2022/2/22 19:38

注:atoi 处理像 00010001 这样的串时会自动变成 11

	else if ((num = s.find(".")) != std::string::npos)
	{
		x = s.substr(0, num), y = s.substr(num + 1);
		char a[1005];
		itoa(atoi(y.c_str()), a, 10);
		std::reverse(a, a + std::strlen(a));
		std::reverse(x.begin(), x.end());
		std::cout << x << "." << y;
	}
2022/2/22 19:38
加载中...