题目不难,用vector存储转换进制的各个位,然后转置一下,进行比较,相等即Yes
#include<iostream>#include<vector>using namespace std;int main(){ int N;; int b; cin >> N >> b; char c; vector<int> vec1,vec2; while (N / b != 0) { vec1.push_back(N%b); N = N / b; } vec1.push_back(N); for (auto it = vec1.rbegin();it != vec1.rend();it++)//转置 vec2.push_back(*it); if (vec1 == vec2) cout << "Yes" << endl<<vec2[0];//判断 else cout << "No" << endl<<vec2[0]; for (unsigned int t = 1;t < vec2.size();t++) cout << " " << vec2[t]; cout << endl;}新闻热点
疑难解答