北邮新OJ95

来源:互联网 发布:网络诈骗 编辑:程序博客网 时间:2024/06/05 22:44

http://code.bupt.edu.cn/problem/p/95/

#include<iostream>#include<stdio.h>#include<stdlib.h>using namespace std;  int main(){    int num[1001];    int n;    int a[1001];    while(scanf("%d",&n)!=EOF)    {        for(int i=1;i<=n;i++)            cin>>num[i];        for(int i=1;i<=n;i++)        {            if(num[i]==0)                cout<<"0"<<endl;            else            {                int temp=num[i];                int k=0;                while(temp!=0)                {                    a[k++]=temp%2;                    temp=temp/2;                }                for(int i=k-1;i>=0;i--)                    cout<<a[i];                cout<<endl;            }        }    }          //system("pause");    return 0;}


0 0
原创粉丝点击