当前位置:网站首页>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;
}
边栏推荐
- Review of various historical versions of Photoshop and system requirements
- 牛客剑指offer--JZ12 矩阵中的路径
- 智慧展厅设计的优势及适用行业分析
- Slashes / and backslashes involved in writing code\
- Create datasource using Druid connection pool
- Dialog introduction
- JVM上篇:内存与垃圾回收篇九--运行时数据区-对象的实例化,内存布局与访问定位
- Standard dialog qmessagebox
- Introduction to dynamic memory functions (malloc free calloc realloc)
- How does PS import LUT presets? Photoshop import LUT color preset tutorial
猜你喜欢

JVM上篇:内存与垃圾回收篇十一--执行引擎

JVM上篇:内存与垃圾回收篇十--运行时数据区-直接内存

Sunyanfang, co-founder of WeiMiao: take compliance as the first essence and become the "regular army" of financial and business education

JVM上篇:内存与垃圾回收篇九--运行时数据区-对象的实例化,内存布局与访问定位

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

Read write separation and master-slave synchronization

Review of various historical versions of Photoshop and system requirements

Could not autowire.No beans of ‘userMapper‘ type found.

标准对话框 QMessageBox

JVM上篇:内存与垃圾回收篇八--运行时数据区-方法区
随机推荐
Standard dialog qmessagebox
Complete Binary Tree
Event
[acwing] solution to the 61st weekly match
pyside2____1.安装和案列
Invert a Binary Tree
Introduction to Web Framework
JVM上篇:内存与垃圾回收篇五--运行时数据区-虚拟机栈
Sub database and sub table
File processing (IO)
TypeScript 详解
深入 Qt5 信号槽新语法
B1030 完美数列
QT menu bar, toolbar and status bar
How idea creates a groovy project (explain in detail with pictures and texts)
Could not autowire. No beans of ‘userMapper‘ type found.
老子云携手福昕鲲鹏,首次实现3D OFD三维版式文档的重大突破
How to create an applet project
How does the TCP server handle multiple client connections on one port (one-to-one or one to many)
Hiding skills of Photoshop clipping tool