ZOJ Problem Set - 1383 Binary Numbers

来源:互联网 发布:如何手机修改淘宝评价 编辑:程序博客网 时间:2024/04/16 22:14

//这道题挺简单的大笑

//题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=383

#include<iostream>using namespace std;int a[10000];int main(){int i, k, m, n;int t;cin >> t;while (t--){cin >> m;n = m;k = 0;while (n > 0){a[k] = n % 2;n = n / 2;k++;}k--;for (i = 0; i < k; i++){if (a[i])cout << i<<" ";}cout << k << endl;}return 0;}

0 0
原创粉丝点击