Re: [問題] 105高三資訊處理 程式語言的 第三題
※ 引述《ssac (吼..)》之銘言:
: 不好意思因為是不同小題 就分開貼了 不是為了賺P幣~XD
: 題目 int main(){
: int a=1,b=2,c=3,d=4;
: prinf("%d %d %d %d ", a+b+c+d , (b*=a) , (a+=d),(d++));
: }
: 補習班的答案
: 10 2 5 4
: 使用gcc的結果
: 26 12 6 4
: 這部份也是覺得推算起來很鬼異~
: 畢竟d++的生效要是下一行 才有反應~?
: 這只是compiler的不同嗎?
先說我沒有考國考 只是個手癢的小RD
case 1:
OS: amazon linux kernel: 3.14.20-20.44.amzn1.x86_64
gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
result:
[ec2-user@ip-xxxxxxxx ~]$ gcc test.c -o test
[ec2-user@ip-xxxxxxxx ~]$ ./test
26
12
6
4
case 2:
OS: linux Mint 17.2 kernel: GNU/Linux 3.16.0-38-generic x86_64
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
result:
luke-PC ~ # gcc test.c -o test
luke-PC ~ # ./test
26
12
6
4
result2:
luke-PC ~ # g++ test.c -o testcplus
luke-PC ~ # ./testcplus
26
12
6
4
case 3:
OS: OS X EI Capitan 10.11.4
Apple LLVM version 7.3.0 (clang-703.0.29) (Xcode 7.3)
tomootekiMacBook-Pro:~ Luke$ gcc test.c -o test
test.c:6:45: warning: unsequenced modification and access to 'b' [-Wunsequenced]
printf( "%d\n%d\n%d\n%d\n", a+b+c+d, (b *= a), (a += d), (d++));
~ ^
test.c:6:55: warning: unsequenced modification and access to 'a' [-Wunsequenced]
printf( "%d\n%d\n%d\n%d\n", a+b+c+d, (b *= a), (a += d), (d++));
~ ^
test.c:6:64: warning: unsequenced modification and access to 'd' [-Wunsequenced]
printf( "%d\n%d\n%d\n%d\n", a+b+c+d, (b *= a), (a += d), (d++));
~ ^
3 warnings generated.
tomootekiMacBook-Pro:~ Luke$ ./test
10
2
5
4
心得是
考試院別鬧了,程式語言鑽這些跟八股文有什麼兩樣
這種考試只考得出補習能力,哪有程式設計能力?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.225.41.39
※ 文章網址: https://www.ptt.cc/bbs/Examination/M.1468391459.A.C13.html
→
07/13 14:53, , 1F
07/13 14:53, 1F
→
07/13 14:53, , 2F
07/13 14:53, 2F
→
07/13 14:55, , 3F
07/13 14:55, 3F
推
07/13 14:57, , 4F
07/13 14:57, 4F
推
07/13 14:57, , 5F
07/13 14:57, 5F
→
07/13 14:59, , 6F
07/13 14:59, 6F
推
07/13 15:01, , 7F
07/13 15:01, 7F
→
07/13 15:03, , 8F
07/13 15:03, 8F
推
07/13 15:08, , 9F
07/13 15:08, 9F
→
07/13 15:14, , 10F
07/13 15:14, 10F
→
07/13 15:15, , 11F
07/13 15:15, 11F
推
07/13 15:36, , 12F
07/13 15:36, 12F
推
07/13 16:36, , 13F
07/13 16:36, 13F
推
07/13 16:54, , 14F
07/13 16:54, 14F
推
07/13 18:49, , 15F
07/13 18:49, 15F
→
07/13 18:50, , 16F
07/13 18:50, 16F
→
07/13 19:03, , 17F
07/13 19:03, 17F
→
07/15 14:39, , 18F
07/15 14:39, 18F
推
07/15 16:44, , 19F
07/15 16:44, 19F
→
07/15 16:44, , 20F
07/15 16:44, 20F
→
07/15 16:46, , 21F
07/15 16:46, 21F
→
07/15 16:47, , 22F
07/15 16:47, 22F
→
07/15 21:24, , 23F
07/15 21:24, 23F
→
07/15 21:27, , 24F
07/15 21:27, 24F
→
07/15 21:29, , 25F
07/15 21:29, 25F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):