摘要: #include <iostream>using namespace std;void DecToBin(unsigned int dec,char ch[] ){ int i = 31; while(i >= 0) { int temp = dec; temp = temp >> i; ch[32-i-1] = (temp & 1)+'0'; i--; }}int main(){ char ch1[33]; DecToBin(12,ch1); ch1[32] = '\0'; cout<<ch1<<e 阅读全文
posted @ 2012-08-22 22:07 SA高处不胜寒 阅读(1810) 评论(0) 推荐(0) 编辑
摘要: 今天好友微软笔试,把题目发给我看了,不过由于英语不好,看了很久才懂,唉,题目如下:Here goes the question: > > Write a method that find the int that has the most occurred number 1 in the input int array, and write test cases that you can think.> > Please return me the answer no later than 20:20.这上面的1当时理解为整形的二进制中的1,则代码如下:#include 阅读全文
posted @ 2012-08-22 21:42 SA高处不胜寒 阅读(167) 评论(0) 推荐(0) 编辑
摘要: const修饰符可以把对象转变成常数对象,什么意思呢?意思就是说利用const进行修饰的变量的值在程序的任意位置将不能再被修改,就如同常数一样使用! 使用方法是:const int a=1;//这里定义了一个int类型的const常数变量a; 但就于指针来说const仍然是起作用的,以下有两点要十分注意,因为下面的两个问题很容易混淆! 我们来看一个如下的例子:#include <iostream>using namespace std;void main(void){const int a=10;int b=20;const int *pi;pi=&a;cout <& 阅读全文
posted @ 2012-08-22 15:51 SA高处不胜寒 阅读(171) 评论(0) 推荐(0) 编辑
摘要: #include <vector>#include <iterator>#include <iostream>using namespace std; void printMy(vector<int>); int main(){ vector<int> vecInt; vecInt.push_back (1); vecInt.push_back (6); vecInt.push_back (6); vecInt.push_back (3); vector<int>::iterator itor; vector<int 阅读全文
posted @ 2012-08-22 15:39 SA高处不胜寒 阅读(557) 评论(0) 推荐(0) 编辑