你的意见 [英] Your opinion

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

问题描述

#define AB

#define BA


main()

{

int A = 5;

浮动B = 6.0;

printf(" \ n%d%f",A,B);

printf("%d%f",B,A);

}


看看这个程序。什么是输出?

是否依赖于实现?


你认为这个问题的目的是在分析一个人的C技能吗? br />
(技术技巧论文中提到)


-

使用M2,Opera的革命性电子邮件客户: http://www.opera.com/m2/

#define A B
#define B A

main()
{
int A=5;
float B=6.0;
printf("\n %d %f",A,B);
printf(" %d %f",B,A);
}

Take a look at this program. What is the output?
Is it implementation dependent?

Do you think this question aim''s at analising a person''s C skills?
(It was asked in a Technical skill paper)

--
Using M2, Opera''s revolutionary e-mail client: http://www.opera.com/m2/

推荐答案

Ravi< me@privacy.net>写道:
Ravi <me@privacy.net> writes:
#define AB
#define BA


无意义,愚蠢,实际上是无操作。

main()


你应该声明main()显式返回`int''。这是C99要求的
。你还应该在

括号内写'void'来给它一个原型,虽然它不是必需的。

{
int A = 5; < br => float B = 6.0;
printf(\ n%d%f,A,B);
printf(%d%f,B,A);


你应该从main()返回一个值。

}

看看这个程序。输出是什么?
是否依赖于实现?


由于至少有两个原因未定义:首先,尝试使用%f打印出int的
;第二,因为没有给stdout写一个最终的

换行符。

你认为这个问题的目的是在分析一个人的C技能吗?
(技术论文中有人问过)
#define A B
#define B A
Pointless and stupid and effectively a no-op besides.
main()
You should declare main() as explicitly returning `int''. This is
required in C99. You should also write `void'' within the
parentheses to give it a prototype, though it is not required.
{
int A=5;
float B=6.0;
printf("\n %d %f",A,B);
printf(" %d %f",B,A);
You should return a value from main().
}

Take a look at this program. What is the output?
Is it implementation dependent?
It is undefined for at least two reasons: first, trying to print
out an `int'' using %f; second, for failing to write a final
new-line character to stdout.
Do you think this question aim''s at analising a person''s C skills?
(It was asked in a Technical skill paper)




我认为它的目的是测试一些东西,但它没有什么可做的

与C技能,特别是考虑到愚蠢的宏

定义。它测试C琐事的知识,而不是C

使用的知识。

-

只是另一个C黑客。



I think it aims at testing something, but it has little to do
with C skills, especially considering the stupid macro
definitions. It tests knowledge of C trivia, not knowledge of C
usage.
--
Just another C hacker.


2003年9月22日星期一21:48:21 +0530,Ravi< me@privacy.net>写道:
On Mon, 22 Sep 2003 21:48:21 +0530, Ravi <me@privacy.net> wrote:
#define
#define BA

main()
{
int A = 5;
浮动B = 6.0;
printf(\ n%d%f,A,B);


未定义的行为。

printf("%d%f",B,A);


未定义的行为三次。

}
#define A B
#define B A

main()
{
int A=5;
float B=6.0;
printf("\n %d %f",A,B);
Undefined behavior.
printf(" %d %f",B,A);
Undefined behavior thrice.
}




尼克。


Nick Austin< ni ********** @ nildram.co.uk>写道:
Nick Austin <ni**********@nildram.co.uk> writes:
2003年9月22日星期一21:48:21 +0530,Ravi< me@privacy.net>写道:
On Mon, 22 Sep 2003 21:48:21 +0530, Ravi <me@privacy.net> wrote:
#define
#define BA

main()
{
int A = 5;
float B = 6.0;
printf(" \ n%d%f",A,B);
#define A B
#define B A

main()
{
int A=5;
float B=6.0;
printf("\n %d %f",A,B);



未定义的行为。



Undefined behavior.




在那行?在哪里?

-

我应该杀死你,你站在哪里,没有价值的人。 --Kaz



In that line? Where?
--
"I should killfile you where you stand, worthless human." --Kaz


这篇关于你的意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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