样例测试通过,但是不知道为啥提交就是0%正确率。。。
#include <bits/stdc++.h> using namespace std; int main(){ string str1,result = ""; int n,t; while(cin >> str1){ //cin >> str1; n = 0; //翻转str1 reverse(str1.begin(),str1.end()); //输出测试1--反转 是否成功 //cout << str1 << endl; for(int i = 0; i < str1.length(); i++){ n += (str1[i]-'0')*pow(2,i); //输出测试2--系数*位权 是否正确 //cout << (str1[i]-'0')*pow(2,i) << endl; } //输出测试3--二进制->十进制 是否ok //cout << n << endl; result = ""; while(n > 0){ t = n % 32; if(t <= 9){result += ('0' + t);} else{result += ('A' + (t-10));} n /= 32; } //输出测试4--十进制->32进制 是否ok //cout << result << endl; //反转 reverse(result.begin(),result.end()); cout << result << endl; } return 0; }
全部评论
(0) 回帖