2013校园招聘---暴风影音---笔试题--输入n,输出对应的所有长度为n的二进制串
2012-10-25 13:27
393 查看
输入1
输出:
0
1
输入3:
输出:
000
001
010
011
100
101
110
111
输出:
0
1
输入3:
输出:
000
001
010
011
100
101
110
111
//暴风影音 2013 校园招聘 笔试题 #include <iostream> #include <math.h> #include <stack> using namespace std; void print(unsigned int n) { int max = pow((double)2,(int)n); unsigned int MASK = 0x00000001; stack<int> s; for(unsigned int i=0; i<max; i++) { for(int j=0; j<n; j++) { s.push(((i & MASK)==MASK) ? 1:0); MASK=MASK<<1; } while(s.size()) { cout << s.top(); s.pop(); } MASK=MASK>>n; cout << endl; } } void main() { print(3); }
相关文章推荐
- c++笔试题-输入n,输出对应的所有长度为n的二进制串
- 在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是重复的数字2或者3
- 输入n,输出对应的所有长度为n的二进制串
- 输入n,输出对应的所有长度为n的二进制串
- 腾讯2013校园招聘技术类笔试题详解
- 输入一个数组长度,动态创建数组,所有元素随机生成,输出元素中的最大值
- 谷歌2013校园招聘笔试题(附答案) 日期 2012年10月15日 有添加自己的解答
- 小米2013校园招聘笔试题-最大连续子序列乘积
- 360 2013校园招聘笔试题(含参考答案)
- 2013豆瓣校园招聘研发类笔试题-B卷
- IGT 2013校园招聘 笔试题
- 百度2013校园招聘移动软件研发工程师笔试题(二)
- 百度2013校园招聘笔试题
- 百度2013校园招聘笔试题(答案整理) – 机器学习/数据挖掘工程师
- 网易2013校园招聘笔试题
- 百度2013校园招聘笔试题(含整理的答案)
- (python)用户输入一段英文,然后输出这段英文中所有长度为3的英文单词
- 百度2013校园招聘笔试题(含自己整理的答案)【转】
- 网易笔试题:输入一个正整数,若该数能用几个连续正整数之和表示,则输出所有可能的正整数序列。
- 【面试笔试-c/c++】兰亭集势2013校园招聘试题。