哨兵控制循环 [英] sentinel control loops
问题描述
大家好。
这是我的简单怀疑
哨兵控制循环是什么意思?
>
推荐答案
Sentinel控制的循环
当要处理未知数量的数据项时,某种方式可以获得$ /
认识到需要结束数据。
一种解决方案是定义一个标记值
a唯一值,表示数据结束
它不能是一个可能作为数据出现的值
代码模板:
sentinel:constant:= ???;
循环
读取(项目);
退出时item = sentinel;
处理项目;
结束循环;
示例:添加用户输入的整数,最多但不包括-1
表示数据结束
tot:= 0;
循环
PUT("输入一个整数(-1退出): );
GET(j); SKIP_LINE;
退出时(j = -1);
tot:= tot + j;
结束循环;
< br $>
-
MistakenIdentity
Sentinel-controlled loops
When an unknown number of data items are to be processed, some way to
recognise the end of the data is needed.
One solution is to define a sentinel value
a unique value that indicates end-of-data
it cannot be a value that could occur as data
Code template:
sentinel : constant := ???;
loop
read (item);
exit when item = sentinel;
process the item;
end loop;
Example: add integers that the user enters, up to but not including -1
for end of data
tot := 0;
loop
PUT("Enter an integer (-1 to exit): ");
GET(j); SKIP_LINE;
exit when (j = -1);
tot := tot + j;
end loop;
-
MistakenIdentity
2005年10月20日02:28:47 - 0700,在comp.lang.c,shan
< sr ********** @ gmail.com>写道:
On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
<sr**********@gmail.com> wrote:
大家好嗨
这是我的简单怀疑
这不是怀疑,它的一个问题。首先,怀疑是一个动词......
哨兵控制循环是什么意思?
Hi to everybody
here is my simple doubt
This isn''t a doubt, its a question. For one thing, doubt is a verb...
What is meant by sentinel control loops ?
循环,其中一些哨兵值控制何时你突然爆发,或者我这么认为
而(1)
{
int x = getchar();
if(x ==''a'')中断;
}
-
Mark McIntyre
CLC常见问题< http://www.eskimo.com/~scs/C-faq/top.html>
CLC自述文件:< http://www.ungerhu.com/jxh/clc.welcome.txt>
---- ==通过Newsfeeds.Com发布 - 无限制 - 未经审查 - 安全Usenet新闻== ----
http://www.newsfeeds.com 世界排名第一的新闻组服务! 120,000多个新闻组
---- = East和West-Coast服务器场 - 通过加密实现全隐私= ----
loops where some sentinel value controls when you break out, or so I
would think
while(1)
{
int x = getchar();
if (x==''a'') break;
}
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Mark McIntyre <毫安********** @ spamcop.net>写道:
Mark McIntyre <ma**********@spamcop.net> writes:
2005年10月20日02:28:47 -0700,在comp.lang.c中,shan
< sr ********** @ gmail.com>写道:
On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
<sr**********@gmail.com> wrote:
大家好嗨
这是我的简单怀疑
Hi to everybody
here is my simple doubt
这不是一个疑问,这是一个问题。首先,怀疑是一个动词......
This isn''t a doubt, its a question. For one thing, doubt is a verb...
我对此表示怀疑。
(是的,怀疑它是一个动词。它也是一个名词。是的,问题更适合在这种情况下的b $ b。)
-
Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti .net / ~kst>
圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。
I have my doubts about that.
(Yes, doubt is a verb. It''s also a noun. And yes, "question" is more
appropriate in this context.)
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
这篇关于哨兵控制循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!