当前位置:网站首页>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;
}
边栏推荐
- 安装Pygame
- How to sinicize the JMeter interface?
- How does the TCP server handle multiple client connections on one port (one-to-one or one to many)
- Be diligent in talking about what sidelines you can do now
- Sunset red warm tone tinting filter LUTS preset sunset LUTS 1
- What is the future development direction of software testing engineers?
- Basic operation of vim
- JVM上篇:内存与垃圾回收篇三--运行时数据区-概述及线程
- Select user stories | the false positive rate of hole state in jushuitan is almost 0. How to do this?
- Two dimensional array summation exercise
猜你喜欢

支付流程如何测试?

QT 菜单栏、工具栏和状态栏

Advantages of smart exhibition hall design and applicable industry analysis

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

JVM上篇:内存与垃圾回收篇三--运行时数据区-概述及线程

Inspiration from "flying man" Jordan! Another "arena" opened by O'Neill

How to import PS style? Photoshop style import tutorial

Raspberry pie RTMP streaming local camera image

How do I reset Photoshop preferences? PS method of resetting preferences

34. Analyze flexible.js
随机推荐
树莓派rtmp推流本地摄像头图像
节流函数的demo——正则表达式匹配
Detailed explanation of mvcc and its principle
MQ message queue is used to design the high concurrency of the order placing process, the generation scenarios and solutions of message squeeze, message loss and message repetition
Dialog introduction
File processing (IO)
How to import PS style? Photoshop style import tutorial
树莓派输出PWM波驱动舵机
Detailed description of binary search tree
Error: cannot read properties of undefined (reading 'then')
Svn usage details
JVM上篇:内存与垃圾回收篇八--运行时数据区-方法区
Acceptance and neglect of events
JVM上篇:内存与垃圾回收篇十四--垃圾回收器
Counting Nodes in a Binary Search Tree
听过最自律的一句话: 那些我难以言表 不作声响
Deep Qt5 signal slot new syntax
C中文件I/O的使用
How to copy Photoshop layers to other documents
ssm框架整合