#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
string str,s;
cin>>str;
int len=str.length();
for(int i=0;i<len;i++)
{
if(str[i]=='0')
s+="0000";
else if(str[i]=='1')
s+="0001";
else if(str[i]=='2')
s+="0010";
else if(str[i]=='3')
s+="0011";
else if(str[i]=='4')
s+="0100";
else if(str[i]=='5')
s+="0101";
else if(str[i]=='6')
s+="0110";
else if(str[i]=='7')
s+="0111";
else if(str[i]=='8')
s+="1000";
else if(str[i]=='9')
s+="1001";
else if(str[i]=='A')
s+="1010";
else if(str[i]=='B')
s+="1011";
else if(str[i]=='C')
s+="1100";
else if(str[i]=='D')
s+="1101";
else if(str[i]=='E')
s+="1110";
else if(str[i]=='F')
s+="1111";
}
cout<<s;
}
return 0;
}任意进制转化为二进制(暴力解决)
最新推荐文章于 2024-03-17 12:29:44 发布
本文介绍了一个简单的C++程序,该程序能够将输入的十六进制字符串转换为对应的二进制字符串。通过逐字符读取并转换的方式实现了从十六进制到二进制的转换。
876

被折叠的 条评论
为什么被折叠?



