日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

微软2013暑期实习笔试题目第5题分析

發布時間:2025/3/20 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微软2013暑期实习笔试题目第5题分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

What is the output of the following code?

{int x = 10;int y = 10;x = x++;y = ++y;printf("%d,%d\n",x,y); }

A.10,10

B.10,11

C.11,10

D.11,11



編譯器實際測試結果

GCC : 11,11

VC: 11,11

TCC:10,11



STD C99?

第6.5.16部分第3條

An assignment operator stores a value in the object designated by the left operand. An
assignment expression has the value of the left operand after the assignment, but is not an
lvalue. Thetype of an assignment expression is the type of the left operand unless the
left operand has qualified type, in which case it is the unqualified version of the type of
the left operand. The side effect of updating the stored value of the left operand shall
occur between the previous and the next sequence point.



VC反匯編結果

x = x++;
004113DC ?mov ? ? ? ? eax,dword ptr [x] ?
004113DF ?mov ? ? ? ? dword ptr [x],eax ?
004113E2 ?mov ? ? ? ? ecx,dword ptr [x] ?
004113E5 ?add ? ? ? ? ecx,1 ?
004113E8 ?mov ? ? ? ? dword ptr [x],ecx ?
y = ++y;
004113EB ?mov ? ? ? ? eax,dword ptr [y] ?
004113EE ?add ? ? ? ? eax,1 ?
004113F1 ?mov ? ? ? ? dword ptr [y],eax ?
004113F4 ?mov ? ? ? ? ecx,dword ptr [y] ?
004113F7 ?mov ? ? ? ? dword ptr [y],ecx ?

到現在為止合理的答案是D

不過,如果令

d = (x = x++);

TCC、VC的輸出,d為10,很費解。


原題

http://www.cnblogs.com/justcxtoworld/archive/2013/04/06/3002719.html

轉載于:https://my.oschina.net/u/269555/blog/121032

總結

以上是生活随笔為你收集整理的微软2013暑期实习笔试题目第5题分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。