求C++编程问题 进制转换1
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/14 17:06:37
求C++编程问题 进制转换1
进制转换1 Time Limit:1000MS Memory Limit:65536K Total Submit:79 Accepted:55 Description 给十进制数n,转成对应的b进制数. Input 整数n,b (0
进制转换1 Time Limit:1000MS Memory Limit:65536K Total Submit:79 Accepted:55 Description 给十进制数n,转成对应的b进制数. Input 整数n,b (0
#include
#include
#include
using namespace std;
int main()
{
int n,m,i;
char c[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char s[1000];
cin>>n>>m;
i=0;
while (n>0)
{
s[i]=c[n%m];
++i;
n/=m;
}
for (int j=i-1;j>=0;--j) cout
#include
#include
using namespace std;
int main()
{
int n,m,i;
char c[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char s[1000];
cin>>n>>m;
i=0;
while (n>0)
{
s[i]=c[n%m];
++i;
n/=m;
}
for (int j=i-1;j>=0;--j) cout