比如 int x=17,c; c=x++*1/6; 还有 int a=3,b=5,c=1; a*=6+(b++)-(++c); 第一个里为什么C=2啊?++的优先级

比如intx=17,c;c=x++*1/6;还有inta=3,b=5,c=1;a*=6+(b++)-(++c);第一个里为什么C=2啊?++的优先级不是比较高吗?为什么不... 比如 int x=17,c;
c=x++*1/6;
还有
int a=3,b=5,c=1;
a*=6+(b++)-(++c);
第一个里为什么C=2啊?++的优先级不是比较高吗?为什么不是X自增1之后再运算呢?
第二个里面括号里的式子不是优先级最高么?b和c在运算过程中的值是多少啊?为什么结果是27?
展开
sunnyapi
2011-07-08 · TA获得超过1032个赞
知道小有建树答主
回答量:376
采纳率:100%
帮助的人:369万
展开全部
楼主您好哦@_@
您的问题我仔细看了一下,也亲自编程运行了一下,应该可以正确解答啦,哈哈~~
第一题:
int x=17,c;
c=x++*1/6;
++的优先级比较高,这不假,但是您要看到++的位置是在x的前面还是后面,本题是在x的后面,那就是说当先完成c=x*1/6;之后再进行x++的运算,所以这句话可以分开写成:
c=x*1/6;//c=17/6=2.8333但是c是int类型,所以小数部分会被丢弃,所以c=2
x++;此时x才变成18,也就是先算出来c之后x才会完成自加运算。

第二题:
int a=3,b=5,c=1;
a*=6+(b++)-(++c);
括号里优先级最高也是没有问题的,楼主您说的对。但是您看b++的++是不是在b的后面?这就是后自加,是完成a的计算之后才会进行的运算。您看
++c的++是不是放在了c的前面?这说明++c要先运算,才会带入新的c的值来计算a
那么a*=6+(b++)-(++c);
等价于 a*=6+b-(c+1)
等价于 a=a*(6+b-(c+1))=3*(6+5-2)=27.

为了您理解的更好,我分别把第一第二题的程序附在后面供您运行哦
第一题:
typedef int zx;
#include<iostream>
using namespace std;
int main()
{
zx x=17;
zx c;
c=x++*1/6;
cout<<c<<"\n";
system("pause");
return 0;
}

第二题

typedef int zx;
#include<iostream>
using namespace std;
int main()
{
zx a=3,b=5,c=1;
a*=6+(b++)-(++c);

cout<<a<<"\n";
system("pause");
return 0;
}
百度网友8747532
2011-07-08 · TA获得超过162个赞
知道小有建树答主
回答量:178
采纳率:0%
帮助的人:123万
展开全部
对于第一个,这是有前置后置的区别的,后置是在参加完运算之后再自增的,前置是自增之后再参加运算的
对于第二个,括号里面的是先运算的,只不过同第一题,++ 有前置后置的区别
对于++在不同的编译器会有不同的表现,一直以来的也有争议的
比如这个式子 i+=(i++)+(++i);不同的编译器可能结果就是不一样的,尽量避免这种状况
追问
第二个算式,括号里算完b等于6才对啊,可等于6算出来结果和VC++上出来的不一样。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
donpshoe507
2011-07-08
知道答主
回答量:72
采纳率:0%
帮助的人:17.5万
展开全部
Being a group we caring a lot what we abrasion in in actuality even if we do not abrasion than additionally we demeanour to a joy turn as good as which competence be a character matter to most some-more. As good as a the single we abrasion as a group out abrasion have been similar to a account they have been certain to be a partial of we in winters though a single some-more affair which is current which they have been similar Tissot watch T02.1.285.82 to a accessories upon a group as these which is a Group Outerwear. As they cannot abrasion most of ornaments though they can beauty there demeanour some-more by a outwears as good as these have been overwhelming seeking a single. These demeanour cold as good as accord a group as good as a boys a demeanour of a timber. They have been overwhelming we do not follower of Jesus louboutin to be amount unwavering as they have been a small lax as good as they will in actuality censor a additional upon we.

Orlando hotels" suggest atmospheric as good as lush room, ensuring which the memories we have have been good ones. Amodations have been entirely versed with Tissot watch T050.207.16.106.00 all sorts of comforts as good as comforts. The bedrooms have been friendly underline the room with the aristocrat bed as good as the apart vital breadth with full-size sleeper lounge, x-ray as good as fridge.

If we sinecure a licence vessel Caribbean, we get a possibility to outing extraordinary places as well as will be means to see a overwhelming places of seductiveness as well as destinations. A continue of this abode is additionally really pleasing which attracts Tissot watch T006.707.11.033.00 a visitors toe to this abode. For any affectionate of jubilee we can make use of a Caribbean sailing yacht licence as well as have a single of a many noted practice of your hold up.

In a Mozilla browser, name Tools / Related Chronicle undo as well as bang upon a arrow subsequent to " Details ". There we select equivalent to Internet Explorer, either story, typed keywords, accolade, accumulation etc. have been to be private. Over a drop-down card during a tip of a window, usually interpretation from a sold duration can be forward to obscurity. Now starts a undo routine, it can additionally save your Dell inspiron mini 9 array energy.

.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式