本文介绍了适当的调用者和打印说明者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/ * C版* /

静态无符号长

t,x = 123456789,y = 362436069,z = 21288629,w = 14921776,c = 0;

unsigned long KISS(){

x + = 545925293;

y ^ =(y<< 13); Y 1 =(Y>> 17); y ^ =(y
t = z + w + c; Z =瓦特; C =(T>> 31); w = t& 2147483647;

return(x + y + w); }

这个函数的适当调用者是什么。我是否正确

静态说明符具有记住其较旧的

变量的功能?

unsigned long function(void)

#include< stdio.h>

int main(无效)

{

unsigned long g;

g = KISS();

printf("%lu \ n",g); / *看起来很近* /

返回0;

}

-

韦德沃德

/* C version */
static unsigned long
t,x=123456789,y=362436069,z=21288629,w=14921776,c= 0;
unsigned long KISS(){
x+=545925293;
y^=(y<<13); y^=(y>>17); y^=(y<<5);
t=z+w+c; z=w; c=(t>>31); w=t&2147483647;
return(x+y+w); }
What would be an appropriate caller for this function. Am I correct
that the static specifier has the function remembering its older
variables?
unsigned long function(void)
#include <stdio.h>
int main(void)
{
unsigned long g;
g=KISS();
printf("%lu\n", g); /*looks close*/
return 0;
}
--
Wade Ward

推荐答案



/ * C版* /

静态无符号长

t,

x = 123456789,

y = 362436069,

z = 21288629,

w = 14921776,

c = 0;

unsigned long KISS ()

{

x + = 545925293;

y ^ =(y
y ^ =(y> 17);

y ^ =(y
t = z + w + c;

z = w;

c =(t> 31);

w = t& 2147483647;

返回(x + y + w);

}

/ *这个函数的适当调用者是什么? />
============================================ ====== ===========

任何需要输出的调用者,只要有一个

执行线程。此函数修改静态数据

因此不可重入。

======================= =========================== ===========

我是否正确静态说明符有函数

记住它的旧变量吗?

======================= =========================== ===========

/* C version */
static unsigned long
t,
x = 123456789,
y = 362436069,
z = 21288629,
w = 14921776,
c = 0;
unsigned long KISS()
{
x += 545925293;
y ^= (y << 13);
y ^= (y >17);
y ^= (y << 5);
t = z + w + c;
z = w;
c = (t >31);
w = t & 2147483647;
return (x + y + w);
}
/* What would be an appropriate caller for this function?
================================================== ===========
Any caller needing its output, provided there is a single
thread of execution. This function modifies static data
and is therefore not reentrant.
================================================== ===========
Am I correct that the static specifier has the function
remembering its older variables?
================================================== ===========



" 5.1.2执行环境

1定义了两个执行环境:独立和托管。在

这两种情况下,当执行环境调用指定的C函数
时,程序启动就会发生。具有静态存储空间的所有对象

持续时间应在

程序启动之前初始化(设置为其初始值)。这种初始化的方式和时间是

否则未指定。程序终止将控制返回到

执行环境。


6.2.4对象的存储持续时间

1 An object具有确定其生命周期的存储持续时间。

是三个存储持续时间:静态,自动和分配。

分配的存储在7.20.3中描述。

2的生命周期对象是

期间程序执行的一部分,保证为其保留存储空间。存在一个对象,

有一个常量地址,25)并且在其整个生命周期内保留其最后存储的值

.26)如果一个对象被引用到它的

生命周期,行为未定义。指针的值变为

当它指向的对象到达

生命周期结束时不确定。

3标识符为声明与外部或内部

链接,或与存储类说明符static静态存储

持续时间。它的生命周期是程序的整个执行,它的

存储值只在程序启动之前初始化一次。

4声明标识符没有链接的对象如果没有

,则存储类说明符static具有自动存储持续时间。

==================== ============================== ===========

* /


#include< stdio.h>

int main(无效)

{

unsigned long g;

g = KISS();

printf("%lu \ n",g); / *看起来很近* /

返回0;

}

"5.1.2 Execution environments
1 Two execution environments are defined: freestanding and hosted. In
both cases, program startup occurs when a designated C function is
called by the execution environment. All objects with static storage
duration shall be initialized (set to their initial values) before
program startup. The manner and timing of such initialization are
otherwise unspecified. Program termination returns control to the
execution environment."

"6.2.4 Storage durations of objects
1 An object has a storage duration that determines its lifetime. There
are three storage durations: static, automatic, and allocated.
Allocated storage is described in 7.20.3.
2 The lifetime of an object is the portion of program execution during
which storage is guaranteed to be reserved for it. An object exists,
has a constant address,25) and retains its last-stored value
throughout its lifetime.26) If an object is referred to outside of its
lifetime, the behavior is undefined. The value of a pointer becomes
indeterminate when the object it points to reaches the end of its
lifetime.
3 An object whose identifier is declared with external or internal
linkage, or with the storage-class specifier static has static storage
duration. Its lifetime is the entire execution of the program and its
stored value is initialized only once, prior to program startup.
4 An object whose identifier is declared with no linkage and without
the storage-class specifier static has automatic storage duration."
================================================== ===========
*/

#include <stdio.h>
int main(void)
{
unsigned long g;
g = KISS();
printf("%lu\n", g); /* looks close */
return 0;
}




如果你需要帮助,你可以做的最少就是尝试使你的代码可以读取
。水平空格和缩进不会增加您的消息成本。

If you want help, the least you could do is try to make your code
readable. Horizontal whitespace and indenting do not increase your
message cost.



如果你的意思是呼叫声明,那么你下面的那个是足够的b / b
。您可以在任何语句中调用KISS,其中表达式为

类型unsigned long。

If you mean calling statement, then the one you have below is
adequate. You could call KISS in any statement where an expression of
type unsigned long would be allowed.



静态限定符意味着

1 - 当你的程序使用
时,对象只会被创建和初始化一次(不起作用)开始。

2 - 对象保持活着状态在你的程序期间

(不是功能)。


这两个声明导致结论是唯一的方式

这些对象通过可执行语句更改值。因为你
永远不会将这些变量的地址传递给另一个函数

(另一个函数可以访问它们的唯一方法),值将是
$ b连续拨打KISS之间$ b保持不变。

The static qualifier means
1 - The objects are created and initialized only once when
your program (not function) starts.
2 - The object remain "alive" for the duration of your program
(not function).

These two statement lead to the conclusion that the only way any of
these objects change value is via an executable statement. Since you
never pass the address of any of these variables to another function
(the only way another function could access them), the values will
remain unchanged between successive calls to KISS.



您对此声明的意图是什么?

What did you intend for this statement?



您有关于调用KISS或打印它的问题\ 0返回值吗?

Is your question about calling KISS or printing it\0 return value?



删除del电子邮件


Remove del for email




。 ...剪断...

.... snip ...



静态限定符意味着

1 - 当你的程序获得
时,对象只会被创建和初始化一次(不起作用)开始。

2 - 对象保持活着状态在你的程序期间

(不是功能)。


The static qualifier means
1 - The objects are created and initialized only once when
your program (not function) starts.
2 - The object remain "alive" for the duration of your program
(not function).



如果应用于某个函数则不会。


-

< http:/ /www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

< http://www.securityfocus.com/columnists/423>

< http://www.aaxnet.com/editor/edit043.html>

cbfalconer at maineline dot net


-

通过 http://www.teranews.com

Not if applied to a function.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com


这篇关于适当的调用者和打印说明者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!