如何不滥用“for循环”:例子? [英] How not to abuse a "for loop": examples?
问题描述
在页面上:
http://www.strath.ac.uk/IT/Docs/Ccou...00000000000000
或
http://tinyurl.com/4ptzs
作者提醒:
" for循环经常被使用,通常循环将是
遍历固定次数。它非常灵活,新手
程序员应该注意不要滥用它提供的功能。
有人可以举一个这种滥用的例子吗?我正在使用Google搜索
c滥用for循环
c滥用for循环
运气不佳。
我想看看*不*做什么:)
托比
2004年8月9日,Toby Newman写道:
作者警告说:
for循环经常被使用,通常是循环所在的地方
遍历了固定的次数。它非常灵活,新手程序员应该注意不要滥用它提供的功能。
有人可以举一个这种滥用的例子吗?我正在谷歌搜索
c滥用for循环
c abusefor for loop
运气不好。
我想要看看*不*做*)
for(a(),b(),c(),d(),e(),f() ,g();
h(),i(),j(),k(),l(),m(),n(),o(),p();
q(),r(),s(),t(),u(),v(),w(),x(),y(),z())
;
Tak-Shing
" Toby Newman" <去**** @ asktoby.com>在消息中写道
news:25 ************************** @ posting.google.c om ...
" for循环经常被使用,通常是循环将被遍历固定次数的地方。它非常灵活,新手程序员应该注意不要滥用它提供的功能。
有人可以举一个这种滥用的例子吗?我正在谷歌搜索
c滥用for循环
c abusefor for loop
运气不好。
我想要看看*不*做*)
for(i = 0; i< 100; i + =(i == 98)? - 97:2 )
for(; * ++ argv
&&(fp = fopen(* argv," rb"))
&& fread(buffer,10,10,fp)== 10
&& fclose(fp)!= EOF;)
虽然,我对两者都有罪。 ;)
-
彼得
Toby Newman写道:
在页面上:
http://www.strath.ac.uk/IT/Docs/Ccou...00000000000000
或
http://tinyurl.com/4ptzs
作者提醒:
for循环频繁使用,通常在循环将遍历固定次数的地方。它非常灵活,新手程序员应该注意不要滥用它提供的功能。
有人可以举一个这种滥用的例子吗?我正在谷歌搜索
c滥用for循环
c abusefor for loop
运气不好。
我想要看看*不*做什么:)
托比
for(i = 0; i< 100; ++ i)
{
- i;
}
浮动j;
for(j = 0.0; j!= 10.0; j + = 0.1)
{
}
unsigned int m;
for(m = 9; m> 0; m - = 2)
{
}
-
Thomas Matthews
C ++新闻组欢迎辞:
http://www.slack.net/~shiva/welcome.txt
C ++常见问题: http://www.parashift.com/c++-faq-lite
C常见问题: http://www.eskimo.com/~scs/c-faq/top.ht ml
alt.comp.lang.learn.c-c ++ faq:
http://www.comeaucomputing.com/learn/faq/
其他网站:
http://www.josuttis.com - C ++ STL图书馆书籍
At the page:
http://www.strath.ac.uk/IT/Docs/Ccou...00000000000000
or
http://tinyurl.com/4ptzs
the author warns:
"The for loop is frequently used, usually where the loop will be
traversed a fixed number of times. It is very flexible, and novice
programmers should take care not to abuse the power it offers."
Could someone give an example of this abuse? I''m googling for
c misuse "for loop"
c abuse "for loop"
with little luck.
I''d like to see what *not* to do :)
Toby
On 9 Aug 2004, Toby Newman wrote:
the author warns:
"The for loop is frequently used, usually where the loop will be
traversed a fixed number of times. It is very flexible, and novice
programmers should take care not to abuse the power it offers."
Could someone give an example of this abuse? I''m googling for
c misuse "for loop"
c abuse "for loop"
with little luck.
I''d like to see what *not* to do :)
for (a(), b(), c(), d(), e(), f(), g();
h(), i(), j(), k(), l(), m(), n(), o(), p();
q(), r(), s(), t(), u(), v(), w(), x(), y(), z())
;
Tak-Shing
"Toby Newman" <go****@asktoby.com> wrote in message
news:25**************************@posting.google.c om...
"The for loop is frequently used, usually where the loop will be
traversed a fixed number of times. It is very flexible, and novice
programmers should take care not to abuse the power it offers."
Could someone give an example of this abuse? I''m googling for
c misuse "for loop"
c abuse "for loop"
with little luck.
I''d like to see what *not* to do :)
for (i = 0; i < 100; i += (i == 98) ? -97 : 2)
for (; *++argv
&& (fp = fopen(*argv, "rb"))
&& fread(buffer, 10, 10, fp) == 10
&& fclose(fp) != EOF; )
Although, I''m guilty of both. ;)
--
Peter
Toby Newman wrote:
At the page:
http://www.strath.ac.uk/IT/Docs/Ccou...00000000000000
or
http://tinyurl.com/4ptzs
the author warns:
"The for loop is frequently used, usually where the loop will be
traversed a fixed number of times. It is very flexible, and novice
programmers should take care not to abuse the power it offers."
Could someone give an example of this abuse? I''m googling for
c misuse "for loop"
c abuse "for loop"
with little luck.
I''d like to see what *not* to do :)
Toby
for (i = 0; i < 100; ++i)
{
--i;
}
float j;
for (j = 0.0; j != 10.0; j += 0.1)
{
}
unsigned int m;
for (m = 9; m > 0; m -= 2)
{
}
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
这篇关于如何不滥用“for循环”:例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!