HDOJ2031(十进制变X进制)
来源:互联网 发布:linux查询端口命令 编辑:程序博客网 时间:2024/05/17 23:17
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <math.h>
using namespace std;
#define N 110
int a[N];
int main()
{
int n, m;
while (cin >> n >> m)
{
int f = 1;
if (n < 0) //负数标记
{
n = -n;
f = 0;
}
int i = 0;
while (n > 0)
{
a[i++] = n%m;
n /= m;
}
if (!f) cout << "-";
for (int j=i-1; j >= 0; j--)
{
if (a[j] < 10) cout << a[j];
else
cout << (char)('A' + (a[j] - 10));
}
cout << endl;
}
}
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <math.h>
using namespace std;
#define N 110
int a[N];
int main()
{
int n, m;
while (cin >> n >> m)
{
int f = 1;
if (n < 0) //负数标记
{
n = -n;
f = 0;
}
int i = 0;
while (n > 0)
{
a[i++] = n%m;
n /= m;
}
if (!f) cout << "-";
for (int j=i-1; j >= 0; j--)
{
if (a[j] < 10) cout << a[j];
else
cout << (char)('A' + (a[j] - 10));
}
cout << endl;
}
}
阅读全文
0 0
- HDOJ2031(十进制变X进制)
- hdoj2031十进制转为任意进制
- 十进制转成X进制
- 十进制 变 二进制
- 十进制变十六进制
- 递归实现十进制转X进制
- 十进制数转换成x进制----栈实现
- C#控制台基础 tostring(x)十进制转成16进制
- O变X
- O变X
- 【hdoj2031】进制转换(10进制转换为2—16进制)
- ACM--HDOJ2031解题报告
- HDOJ2031 进制转换
- HDOJ2031 进制转换
- 进制转换-HDOJ2031
- 2014-12-10 hdoj2031
- hdoj2031进制转换
- cocos2d-x 精灵变灰
- 从零开始前端学习[26]:html5的一些常用标签,header,footer,section,aside,figure,figcaption,nav,artical,
- 爬虫笔记(9/27)------常用爬虫(图片,链接,内容)
- Python_解析xml
- 1248 寒冰王座 换个思维来解决这个背包题目
- MOOC清华《VC++面向对象与可视化程序设计》第3章:Windows文本-例(2)字体、颜色、下划线
- HDOJ2031(十进制变X进制)
- Hql
- [python]leetcode(22). Generate Parentheses
- Python练手程序-04
- 图片上传到网络上
- LeetCode Blog for course "Algorithms" -- Problem 3 & 5
- windows 保存git的账号密码
- CodeForces
- 开源C++服务端知多少