数据结构——栈与队列进制转换
2017-10-07 16:36
375 查看
数据结构实验之栈与队列一:进制转换
Time Limit: 1000MSMemory Limit: 65536KB
Submit
Statistic
Problem Description
输入一个十进制非负整数,将其转换成对应的 R (2 <= R <= 9) 进制数,并输出。Input
第一行输入需要转换的十进制非负整数;第二行输入 R。
Output
输出转换所得的 R 进制数。Example Input
1279 8
Example Output
2377
Hint
01 | #include<iostream> |
02 | #include<stack> |
03 | using namespace std; |
04 | int main() |
05 | { |
06 | int n,m; |
07 | cin>>n>>m; |
08 | stack< int >s; |
09 | if (n==0) |
10 | { |
11 | cout<< "0" <<endl; |
12 | } |
13 | while (n) |
14 | { |
15 | s.push(n%m); |
16 | n=n/m; |
17 | } |
18 | while (!s.empty()) |
19 | { |
20 | cout<<s.top(); |
21 | s.pop(); |
22 | } |
23 | return 0; |
24 | } |
25 |
26
27 | /*************************************************** |
28 | User name: jk160618郭衣鹏 |
29 | Result: Accepted |
30 | Take time: 0ms |
31 | Take Memory: 200KB |
32 | Submit time: 2017-10-07 16:29:07 |
33 | ****************************************************/ |
相关文章推荐
- SDUT 2131 数据结构实验之栈与队列一:进制转换
- SDUT-2131 数据结构实验之栈与队列一:进制转换
- 数据结构实验之栈与队列一:进制转换
- 2131 数据结构实验之栈与队列一:进制转换
- 2131-数据结构实验之栈与队列一:进制转换
- 数据结构实验之栈与队列一:进制转换
- C语言 数据结构之栈与队列 数据结构实验之栈与队列一:进制转换
- 数据结构实验之栈与队列一:进制转换
- 数据结构——链表、栈和队列
- 数据结构(Java)--栈和队列
- 数据结构之队列
- 数据结构(ZKNU OJ) 周末舞会(循环队列解法)
- 数据结构作业——buzhidao(队列)
- Linux C 数据结构——队列
- 数据结构(五):队列
- 数据结构之顺序队列(循环队列)
- 【数据结构与算法】(四) c 语言静态队列的简单实现
- 数据结构之队列【转】
- 数据结构——链队列
- 寒假第三天--栈和队列--数据结构实验之栈四:括号匹配 (数组)