进制转换2
2015-06-09 10:25
363 查看
数据结构实验之栈一:进制转换
TimeLimit: 1000ms Memory limit: 65536K
有疑问?点这里^_^
题目描述
输入一个十进制整数,将其转换成对应的R(2<=R<=9)进制数,并输出。
输入
第一行输入需要转换的十进制数;
第二行输入R。
输出
输出转换所得的R进制数。
示例输入
1279
8
示例输出
2377
TimeLimit: 1000ms Memory limit: 65536K
有疑问?点这里^_^
题目描述
输入一个十进制整数,将其转换成对应的R(2<=R<=9)进制数,并输出。
输入
第一行输入需要转换的十进制数;
第二行输入R。
输出
输出转换所得的R进制数。
示例输入
1279
8
示例输出
2377
#include <map> #include <set> #include <cmath> #include <stack> #include <queue> #include <cstdio> #include <cctype> #include <vector> #include <string> #include <climits> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #define RR freopen("input.txt","r",stdin) #define WW freopen("output.txt","w",stdout) #define INF 0x3f3f3f3f using namespace std; int main() { int n,m; cin>>n>>m; if(n==0) { cout<<0<<endl; } else { if(n<0) { cout<<'-'; n=-n; } stack<int>B; while(n) { B.push(n%m); n/=m; } while(!B.empty()) { cout<<B.top(); B.pop(); } cout<<endl; } return 0; }
相关文章推荐
- 文件加密之后下载时间变长
- android 自定义view 圆形进度条
- ios开发所需图片尺寸汇总
- iOS定位--CoreLocation
- 进制转换2 分类: 栈和队列 2015-06-09 10:25 14人阅读 评论(0) 收藏
- JavaScript中reduce()方法的使用详解
- Linux-管理文件权限和所有权
- Python扫描IP段查看指定端口是否开放的方法
- rails常用命令
- JS中的Prototype
- Ext实现waiting提示功能
- Factorial Trailing Zeroes
- Leetcode之Database篇
- Apache启动提示错误undefined symbol: libiconv_open解决方法
- 安卓LISTVIEW
- Objective-C中NSLog输出格式大全
- 将svn服务注册成windows服务
- poj 3169 spfa 差分约束
- GitHub超详细图文攻略 - Git客户端下载安装 GitHub提交修改源码工作流程 Git分支 标签 过滤 Git版本工作流
- 进制转换