一些棘手的问题 [英] some tricky questions

查看:60
本文介绍了一些棘手的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)void foo(char * s,char * t)

{

while(* s ++ = * t ++);

}


哪个C函数相当于foo?


2)#define ROUND(x,n)

((x + n-1)&(〜(n-1)))

什么是ROUND的值(223,64)?

描述它是怎么回事?


3)void foo(int x)

{

int i = 0 ;

而(x)

{

x = x&(x-1);

i ++; < br $>
}

printf("%d",i);

}

什么是o / p这个功能&为什么会这样?

这个&的功能是什么?

4)union {

int i;

char c [sizeof(int)];

} x;

xi = 1;

if(xc [ 0] == 1)

printf(m / c是_______________ endian);

else

printf(" m / c是_______________ endian);


用正确的选项填空:

a)小,大b)大,大

c)大,小d)小,小


5)int fun2(char * a,char * b)

{

for(; * a == * b; a ++,b ++)

if(* a ==''\''')

返回0;


返回* a- * b;

}

char a [10] =" date", b [10] =" data;


fun2(a,b)的值是多少?

1) void foo(char *s,char *t)
{
while(*s++=*t++);
}

which C function is equivalent to foo ?

2) #define ROUND(x,n)

((x+n-1)&(~(n-1)))
what is hte value of ROUND(223,64) ?
DESCRIBE IT HOW IT IS SO?

3) void foo(int x)
{
int i=0;
while(x)
{
x=x&(x-1);
i++;
}
printf("%d",i);
}
what is the o/p of this function & why it is so ?
what function does this ''&'' does ?
4) union{
int i;
char c[sizeof(int)];
}x;
x.i=1;
if(x.c[0]==1)
printf("the m/c is _______________ endian");
else
printf("the m/c is _______________ endian");

fill in the blanks with tthe correct option:
a) little,big b)big,big
c) big,little d)little,little

5) int fun2(char *a,char *b)
{
for(; *a==*b;a++,b++)
if(*a==''\0'')
return 0;

return *a-*b;
}
char a[10]="date",b[10]="data";

what is the value of fun2(a,b)?

推荐答案

bi ********** @ gmail.com 写道:

1)void foo(char * s,char * t)

{

while(* s ++ = * t ++);


}


哪个C函数相当于foo?
1) void foo(char *s,char *t)
{
while(*s++=*t++);
}

which C function is equivalent to foo ?



仅供参考,我们不做作业。


-

Tor< ; torust [at] online [dot] no>

FYI, we don''t do homework.

--
Tor <torust [at] online [dot] no>




< bi ********** @ gmail。 comha scritto nel Messaggio

news:11 ********************** @ n15g2000prd.googlegr oups.com ...

<bi**********@gmail.comha scritto nel messaggio
news:11**********************@n15g2000prd.googlegr oups.com...

1)void foo(char * s,char * t)

{

while(* s ++ = * t ++ );


}


哪个C函数相当于foo?
1) void foo(char *s,char *t)
{
while(*s++=*t++);
}

which C function is equivalent to foo ?



无。 strcpy返回与其第一个参数相等的char *。另外,strcpy的

第二个参数是一个const char *。

None. strcpy returns a char* equal to its first argument. Also, the
second argument of strcpy is a const char*.


2)#define ROUND(x,n)


((x + n-1)&(〜 (n-1)))

什么是ROUND的值(223,64)?

描述它是如何做的?
2) #define ROUND(x,n)

((x+n-1)&(~(n-1)))
what is hte value of ROUND(223,64) ?
DESCRIBE IT HOW IT IS SO?



当然是((223 + 64-1)&(〜(64-1)))的值。

It is the value of ((223+64-1)&(~(64-1))), of course.


3)void foo(int x)

{

int i = 0;

while( x)

{

x = x&(x-1);

i ++;

}

printf("%d",i);

}

此功能的o / p是什么?为什么会这样?

这个&的功能是什么?
3) void foo(int x)
{
int i=0;
while(x)
{
x=x&(x-1);
i++;
}
printf("%d",i);
}
what is the o/p of this function & why it is so ?
what function does this ''&'' does ?



如果x是INT_MIN,则允许让恶魔飞出你的鼻子。

BTW,什么是o / p?并且''&''没有功能,至少在C

意义上。

If x is INT_MIN, it is allowed to make demons fly out of your nose.
BTW, what is an o/p? And the ''&'' does no "function", at least in the C
sense.


4)union {

int i;

char c [sizeof(int)];

} x;

xi = 1 ;

if(xc [0] == 1)

printf(m / c是_______________ endian);

else

printf(m / c是_______________ endian);


用正确的选项填空:

a)小,大b)大,大
4) union{
int i;
char c[sizeof(int)];
}x;
x.i=1;
if(x.c[0]==1)
printf("the m/c is _______________ endian");
else
printf("the m/c is _______________ endian");

fill in the blanks with tthe correct option:
a) little,big b)big,big
c) big,little d)little,little



不。它可能是中端。如果我没错,标准

没有指定位顺序。在一致的实现中,它可以是sizeof(int)== 2&& CHAR_BIT == 8,

我的第一个字节可以按顺序包含第一,第三,第五,第七,

第九,第十一,第十三和第十五位,并且

第二个字节可能包含第16个,第14个,......第二位

那个订单。

Nope. It could be middle endian. And if I''m not wrong, the standard
specifies nothing about the bit order. On a conforming implementation, it
could be sizeof (int) == 2 && CHAR_BIT ==8, and
the first byte of i could contain the first, third, fifth, seventh,
ninth, eleventh, thirteenth, and fifteenth bit in that order, and
the second byte could contain the sixteenth, fourteenth, ..., second bit in
that order.


5)int fun2(char * a,char * b)

{

for(; * a == * b; a ++,b ++)

if(* a ==''\''')

返回0;


return * a- * b;

}

char a [10] =" date",b [10] =" data";


fun2(a,b)的价值是多少?
5) int fun2(char *a,char *b)
{
for(; *a==*b;a++,b++)
if(*a==''\0'')
return 0;

return *a-*b;
}
char a[10]="date",b[10]="data";

what is the value of fun2(a,b)?



这是''e'' - ''a'',没有什么要求是4。从CHAR_MIN - CHAR_MAX到-1包括任何东西都可以是

,它可以是

从1到CHAR_MAX - 包括CHAR_MIN的任何东西。不是全世界

使用ASCII。

It is ''e'' - ''a'', which nothing requires to be four. It could be
anything from CHAR_MIN - CHAR_MAX to -1 included, and it could be
anything from 1 to CHAR_MAX - CHAR_MIN included. Not all the world
uses ASCII.


6月2日下午12:28,Army1987 < please .... @ for.itwrote:
On Jun 2, 12:28 pm, "Army1987" <please....@for.itwrote:

< birensubu ... @ gmail.comha scritto nel messaggionews:11 ******* *************** @ n15g2000prd .googlegroups.com ...


[...]
<birensubu...@gmail.comha scritto nel messaggionews:11**********************@n15g2000prd .googlegroups.com...

[...]

2)#define ROUND(x,n)
2) #define ROUND(x,n)


((x + n-1)&(〜( n-1)))

ROUND的值是多少(223,64)?

如何描述它是怎么回事?
((x+n-1)&(~(n-1)))
what is hte value of ROUND(223,64) ?
DESCRIBE IT HOW IT IS SO?



当然是((223 + 64-1)&(〜(64-1)))的值。

[...]


It is the value of ((223+64-1)&(~(64-1))), of course.
[...]



原因:按定义。

[:]] - | - <


/每


-


每个Erik Strandberg

home: www.pererikstrandberg.se

work: www.incf.org

还: www.spongswedencare.se

The reason: "by definition".
[:)]-|--<

/Per

--

Per Erik Strandberg
home: www.pererikstrandberg.se
work: www.incf.org
also: www.spongswedencare.se


这篇关于一些棘手的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆