1, 已知一个32位的字, 请给出一个高效的算法计算其中1的个数,可以
使用临时变量。
这个我实在没有好办法,我觉得唯一的办法就是写一个循环进行移位。
2,下面是两个变量的声明,请把那个数组初始化为零,且不能增加任何
其他变量。
unsigned char c;
int x[257];(刚才错写成256了)
这到题的那点是数组x长度为257,使用变量c进行循环的话会溢出。
我的土方法:
for(c=0; c < 255; c ++){
x[c] = 0;
x[c + 1] = 0;
}
3.
unsigned long val;
char a=0x96;
char b=0x81;
val= b<<8 | a;
问val=___?
4. 写一个函数互换两个变量,但不能用到第三个变量.
5. What is wrong with the following code? Write a main() to print “hello” using
the function f().
void f(char** p)
{
printf(“%s”, p[0]);
}
void main()
{
char a[50][50];
strcpy(a[0], “hello”);
f(a);
}
6. Coding Problem:
"The most obnoxious book I have in my bookshelf is one that somebody
bought my baby daughter... Runny Babbit: A Billy Sook by Shel
Silverstein. Information on this book (in case you want to torture a
parent) can be found at
http://www.amazon.com/gp/product/0060256532/sr=8-1/qid=1139876282/ref=pd
_bbs_1/104-0687593-6578327?%5Fencoding=UTF8 - and a good close-up from
one of the pages in the book can be seen at
http://webcontent.harpercollins.com/images/interior/bookseller_spreads/0
060256532.interior01.jpg. Your programming task is to create a Runny
Babbit translator. I should be able to compile your program (language
of your choice), use it to type in any paragraph of English text (end at
blank line), and have it type back a paragraph translated into Runny
Babbit language. Your output doesn't have to be a perfect match to the
samples in the book - but document any assumptions you make in your code
regarding translation rules."
7. c里面有几种调用序列?
8. 如何用一句不带循环的C语句来判断一个数是否是2的幂
a & (a-1)
9. char *strcpy(char *strDest, const char *strSrc);
{
assert((strDest!=NULL) && (strSrc !=NULL));
char *address = strDest;
while( (*strDest++ = * strSrc++) != ‘\0’ )
NULL ;
return address ;
}
没有评论:
发表评论