for语句中的多个更新 [英] multiple updates in for statement

查看:92
本文介绍了for语句中的多个更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的我如何实现:


#define MYCONST 10

for(int i = 0; i< MYCONST; i ++, j--)

{

}


这是我想在for语句的最后部分有两个项目。

谢谢

迈克

Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.
Thanks
Mike

推荐答案



" Michael" < SL *********** @ hotmail.com>在消息中写道

news:c8 ********** @ hercules.btinternet.com ...

"Michael" <sl***********@hotmail.com> wrote in message
news:c8**********@hercules.btinternet.com...
好我如何实施:

#define MYCONST 10

for(int i = 0; i< MYCONST; i ++,j--)
{
}
这就是我想在for语句的最后部分有两个项目。
谢谢
Mike
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.
Thanks
Mike




我什么也看不见你发布了什么错了。当你编译/运行它时会发生什么?


john



I don''t see anything wrong with what you''ve posted. What happens when you
compile/run it?

john


Michael写道:
Michael wrote:
好我该如何实现:

#define MYCONST 10

for(int i = 0; i< MYCONST; i ++,j - )
{
}
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}




你的实施是对的。

我不明白你在问什么...


- Dario



Your implementation is right.
I do not understand what are you asking...

- Dario




" Michael" < SL *********** @ hotmail.com>在消息中写道

news:c8 ********** @ hercules.btinternet.com ...

"Michael" <sl***********@hotmail.com> wrote in message
news:c8**********@hercules.btinternet.com...
好我如何实施:

#define MYCONST 10

for(int i = 0; i< MYCONST; i ++,j--)
{
}
这就是我想在for语句的最后一部分中有两个项目。
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.




假设j在某处被定义,你就没事了。如果不是


for(int i = 0,j = MYCONST; i!= MYCONST; ++ i, - j)

{

}


Jeff F



Assuming j is defined somewhere, you''re fine as is. If not how about:

for( int i = 0, j = MYCONST ; i != MYCONST ; ++i, --j )
{
}

Jeff F


这篇关于for语句中的多个更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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