大佬看看 为什么4个点全错

#include<iostream>
#include<cmath>
#include<vector>
#include<string.h>
using namespace std;
int Get_Huiwen(int n);
bool Is_Huiwen(int n);
int Len;
int main(){
int n;
cin >> n;
char nums[10001] = { 0 };
cin >> nums;
Len=strlen(nums);
//n进制转换成10进制
int number = 0;
if (n >= 2 && n <= 10){
for (int i = Len-1; i >=0; i--){
number += (int(nums[i]) - 48)*pow(n,Len-1-i);
}
}
else if (n == 16){
for (int i = Len - 1; i >= 0; i--){
if (nums[i] >= '0'&&nums[i] <= '9'){
number += (int(nums[i]) - 48)*pow(n, Len - 1 - i);
}
else if (nums[i] >= 'A'&&nums[i] <= 'F'){
number += (int(nums[i]) - 55)*pow(n, Len - 1 - i);
}
}
}
int lable = 0;
while (true){
if (Is_Huiwen(number)){
cout << "STEP=" << lable;
break;
}
else{
number += Get_Huiwen(number);
lable++;
if (lable > 30){
cout << "Impossible!";
break;
}
}
}
return 0;
}
int Get_Huiwen(int n){
int new_num = 0;
vector<int>num;
while (true){
if (n == 0){
break;
}
num.push_back(n % 10);
n = n / 10;
}
int Len = num.size();
for (int i = 0; i < Len; i++){
new_num += num[i] * pow(10, Len - 1 - i);
}
return new_num;
}
bool Is_Huiwen(int n){
bool end;
if (n == Get_Huiwen(n)){
end = true;
}
else{
end = false;
}
return end;
}

0 条评论

目前还没有评论...

信息

ID
1304
难度
5
分类
模拟 点击显示
标签
递交数
8084
已通过
2535
通过率
31%
被复制
33
上传者