HDU2051(数制转换)
2014-12-16 07:38
190 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2051
解题思路:
朴素的把十进制转化为二进制。
完整代码:
解题思路:
朴素的把十进制转化为二进制。
完整代码:
#include <functional> #include <algorithm> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <numeric> #include <cstring> #include <climits> #include <cassert> #include <complex> #include <cstdio> #include <string> #include <vector> #include <bitset> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <list> #include <set> #include <map> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") typedef long long LL; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; /** Constant List .. **/ //{ const int MOD = int(1e9)+7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; const int maxn = 100001; int ans[maxn]; void solve(int n) { memset(ans , 0 , sizeof(ans)); int cnt = 0; while( n != 0) { int t = n % 2; ans[cnt++] = t; n /= 2; } for(int i = cnt - 1 ; i >= 0 ; i --) cout << ans[i] ; cout <<endl; } int main() { #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int n; while(cin >> n) { solve(n); } }
相关文章推荐
- 数据结构(严蔚敏)顺序栈_数制转换
- 栈的简单应用(数制转换、括号匹配检验、行编辑、迷宫求解)
- 数制转换_顺序栈_头文件
- USACO Palindromic Squares (数制转换)
- 题目44:数制转换
- 栈——数制转换
- 九度OnlineJudge题目1118:数制转换
- 数据结构--栈的基本操作及应用(数制转换)
- 数据结构实验五——栈实现数制转换
- 数制转换
- 数制转换及原码补码反码问题
- 第6周项目4--数制转换
- 第六周项目4-数制转换
- 第六周项目4数制转换
- 2015年大二上-数据结构-栈(4)- 数制转换
- 递归_数制转换(十转其他进制)
- 数制转换问题
- 第五周-- 项目4 - 数制转换
- 第5周项目4-数制转换
- 第五周项目4—数制转换