当前位置:网站首页>B1022 D进制的A+B
B1022 D进制的A+B
2022-07-27 05:01:00 【叶辰 .】
1022 D进制的A+B (20 分)
输入两个非负 10 进制整数 A 和 B (≤2 的30次方−1),输出 A+B 的 D (1<D≤10)进制数。
输入格式:
输入在一行中依次给出 3 个整数 A、B 和 D。
输出格式:
输出 A+B 的 D 进制数。
输入样例
123 456 8
输出样例
1103
题目分析:
- while进制转换
代码如下:
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,x;
cin>>a>>b>>x;
int number=a+b,line[1010],n=0;
while(number){
line[n]=number%x;
number/=x;
n++;
}
for(int i=n-1;i>=0;i--){
cout<<line[i];
}
if(!n) cout<<"0";//注意特殊输入
return 0;
}
边栏推荐
- 使用Druid连接池创建DataSource(数据源)
- 微淼联合创始人孙延芳:以合规为第一要义,做财商教育“正规军”
- 二、MySQL高级
- Dialog data transfer
- How to sinicize the JMeter interface?
- TypeScript 详解
- JVM上篇:内存与垃圾回收篇七--运行时数据区-堆
- [Niuke discussion area] Chapter 7: building safe and efficient enterprise services
- Acticiti中startProcessInstanceByKey方法在variable表中的如何存储
- How to copy Photoshop layers to other documents
猜你喜欢

JVM上篇:内存与垃圾回收篇二--类加载子系统

Tcp server是如何一个端口处理多个客户端连接的(一对一还是一对多)

Select user stories | the false positive rate of hole state in jushuitan is almost 0. How to do this?

智慧展厅设计的优势及适用行业分析

Another skill is to earn 30000 yuan a month+

How to copy Photoshop layers to other documents

Svn usage details

Raspberry pie RTMP streaming local camera image

35. Scroll

When using Photoshop, the prompt "script error -50 general Photoshop error appears“
随机推荐
Explore the mysteries of the security, intelligence and performance of the universal altek platform!
智慧展厅设计的优势及适用行业分析
Jmeter 界面如何汉化?
JVM上篇:内存与垃圾回收篇三--运行时数据区-概述及线程
使用Druid连接池创建DataSource(数据源)
Counting Nodes in a Binary Search Tree
Event
辗转相除法
JVM上篇:内存与垃圾回收篇十二--StringTable
Standard dialog qmessagebox
SVN使用详解
I've heard the most self disciplined sentence: those I can't say are silent
文件对话框
Introduction to Kali system ARP (network disconnection sniffing password packet capturing)
Summary of knowledge points (I)
抽卡程序模拟
文件处理(IO)
Counting Nodes in a Binary Search Tree
pyside2____1.安装和案列
JVM上篇:内存与垃圾回收篇十--运行时数据区-直接内存