ACM习题 All your base
来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/05/21 21:32:40
ACM习题 All your base
All your base
Given a base, and two positive integers in decimal (base 10), convert the two numbers to the new base, add them, and display their sum in the new base.
Input
Three positive integers denoting the base and the two numbers, respectively. Input numbers will be integers between 0 and 65535. Bases will be between 2 and 10 inclusive. Each case will be on a separate line. The end of input will be denoted by three zeros.
Output
An equation for the sum of the two numbers, in the new base.
Example
In this example, we add 10 and 3 in base 2, and we add 15 and 4 in base 3.
In base 2, 10 = 8 + 2 = 1*23 + 0*22 + 1*21 + 0*20 and 3 = 2 + 1 = 1*21 + 1*20, so their base 2 equivalents are 1010 and 11, respectively. 10 + 3 = 13 = 1*23+1*22+0*21+1*20, so the base 2 equivalent of 13 is 1101.
In base 3, 15 = 9 + 6 = 1*32+2*31+0*30 and 4 = 3 + 1 = 1*31 + 1*30, so their base 2 equivalents are 120 and 11, respectively. 15 + 4 = 19 = 2*32 + 0*31 + 1*30, so the base 3 equivalent of 19 is 201.
Input
2 10 3
3 15 4
0 0 0
Output
1010 + 11 = 1101
120 + 11 = 201
All your base
Given a base, and two positive integers in decimal (base 10), convert the two numbers to the new base, add them, and display their sum in the new base.
Input
Three positive integers denoting the base and the two numbers, respectively. Input numbers will be integers between 0 and 65535. Bases will be between 2 and 10 inclusive. Each case will be on a separate line. The end of input will be denoted by three zeros.
Output
An equation for the sum of the two numbers, in the new base.
Example
In this example, we add 10 and 3 in base 2, and we add 15 and 4 in base 3.
In base 2, 10 = 8 + 2 = 1*23 + 0*22 + 1*21 + 0*20 and 3 = 2 + 1 = 1*21 + 1*20, so their base 2 equivalents are 1010 and 11, respectively. 10 + 3 = 13 = 1*23+1*22+0*21+1*20, so the base 2 equivalent of 13 is 1101.
In base 3, 15 = 9 + 6 = 1*32+2*31+0*30 and 4 = 3 + 1 = 1*31 + 1*30, so their base 2 equivalents are 120 and 11, respectively. 15 + 4 = 19 = 2*32 + 0*31 + 1*30, so the base 3 equivalent of 19 is 201.
Input
2 10 3
3 15 4
0 0 0
Output
1010 + 11 = 1101
120 + 11 = 201
#include
using namespace std;
int tran(int base,int n)
{
int a[50];
int i=0,j;
while(n!=0)
{
a[i]=n%base;
n=n/base;
i++;
}
for(j=i-1;j>=0;j--)
coutbase>>a>>b)
{
if(base==0&&a==0&&b==0)
break;
tran(base,a);
cout
using namespace std;
int tran(int base,int n)
{
int a[50];
int i=0,j;
while(n!=0)
{
a[i]=n%base;
n=n/base;
i++;
}
for(j=i-1;j>=0;j--)
coutbase>>a>>b)
{
if(base==0&&a==0&&b==0)
break;
tran(base,a);
cout
all your base are be long tous
"All your base are belong to us"这句话到底怎么了
of base-all for you 歌词~
All you base are belong to us
We suggest you----------your choice on your interests A.base
ACM 习题:高手给个思路.不要穷举法,超时!
What was your invention ____?base on 还是based on?
英语翻译Sorry about your base location being incorrect.可以吗
一首英文歌帮忙翻译 ALL FOR YOU Ace of Base - All For You Lyrics (VERS
英语翻译choruscall all your boyscall all your girlscall all your
left your people left your base that will make you cheap and
《All in your mind》