怎么转进制?懵了。
查看原帖
怎么转进制?懵了。
1361688
gold_boy_hetao楼主2024/7/17 21:41

大佬们救命呀!我要发癫了!!不会转进制呀!!!

#include <iostream>
using namespace std;
bool hw(int x)
{
	int y = x,ans = 0;
	while (y > 0)
	{
		ans *= 10;
		ans += y % 10;
		y /= 10;
	}
	if (x == ans)
		return true;
	else
		return false;
}
int dgl(int x)
{
	int ans = 0;
	while (x > 0)
	{
		ans *= 10;
		ans += x % 10;
		x /= 10;
	}
	return ans;
}
int main()
{
	int n,m;
	cin >> n >> m;
	for (int i = 1;i <= 30;i++)
	{
		int o = dgl(m);
		if (hw(o + m))
		{
			cout << "STEP=" << i;
			return 0;
		}
	}
	cout << "Impossible!";
	return 0;
}

菜鸡一枚,多多关照......

2024/7/17 21:41
加载中...