1015

Posted Si考者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1015相关的知识,希望对你有一定的参考价值。

题目大意:

Problem Description
Give you a number on base ten,you should output it on base two.(0 < n < 1000)
 

 

Input
For each case there is a postive number n on base ten, end of file.
 

 

Output
For each case output a number on base two.
 

 

Sample Input
1 2 3
 

 

Sample Output
1 10 11
十进制转二进制
解题思路:
按照定义,对二求余
代码:
#include <iostream>
using namespace std;
int main()
{
    int a,i;
    int b[100];
    while(cin>>a)
    {
        i=0;
        while(a!=0)
        {
            b[i]=a%2;
            a/=2;
            i++;
        }
        for(i--;i>=0;i--)
            cout<<b[i];
        cout<<endl;
    }
    return 0;
}

 

以上是关于1015的主要内容,如果未能解决你的问题,请参考以下文章

我应该使用 ScrollView 还是 RecyclerView 在片段中滚动?

片段实例中带有 Otto 事件总线的 IllegalArgumentException

导航到目的地时仅创建一个片段实例(android)

1015. Reversible Primes

PAT1015:Reversible Primes

tyvj1015公路乘车——DP