105高三資訊處理 程式語言的 第三題 - 考試
By Audriana
at 2016-07-13T14:30
at 2016-07-13T14:30
Table of Contents
※ 引述《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
心得是
考試院別鬧了,程式語言鑽這些跟八股文有什麼兩樣
這種考試只考得出補習能力,哪有程式設計能力?
--
: 不好意思因為是不同小題 就分開貼了 不是為了賺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
心得是
考試院別鬧了,程式語言鑽這些跟八股文有什麼兩樣
這種考試只考得出補習能力,哪有程式設計能力?
--
Tags:
考試
All Comments
By Blanche
at 2016-07-16T14:49
at 2016-07-16T14:49
By Noah
at 2016-07-19T12:28
at 2016-07-19T12:28
By Adele
at 2016-07-24T00:00
at 2016-07-24T00:00
By Aaliyah
at 2016-07-24T01:59
at 2016-07-24T01:59
By Erin
at 2016-07-24T19:58
at 2016-07-24T19:58
By Valerie
at 2016-07-24T22:35
at 2016-07-24T22:35
By David
at 2016-07-26T02:42
at 2016-07-26T02:42
By Charlotte
at 2016-07-28T01:26
at 2016-07-28T01:26
By Hardy
at 2016-07-31T14:58
at 2016-07-31T14:58
By Connor
at 2016-08-04T08:05
at 2016-08-04T08:05
By Brianna
at 2016-08-08T04:29
at 2016-08-08T04:29
By Selena
at 2016-08-08T13:58
at 2016-08-08T13:58
By Jack
at 2016-08-11T05:33
at 2016-08-11T05:33
By Hazel
at 2016-08-11T11:46
at 2016-08-11T11:46
By Wallis
at 2016-08-15T21:57
at 2016-08-15T21:57
By Agatha
at 2016-08-19T20:49
at 2016-08-19T20:49
By Ophelia
at 2016-08-20T10:19
at 2016-08-20T10:19
By Elizabeth
at 2016-08-24T19:05
at 2016-08-24T19:05
By Frederica
at 2016-08-27T11:32
at 2016-08-27T11:32
By Caroline
at 2016-08-31T05:03
at 2016-08-31T05:03
By Jessica
at 2016-08-31T10:22
at 2016-08-31T10:22
By Vanessa
at 2016-09-01T19:21
at 2016-09-01T19:21
By Audriana
at 2016-09-06T01:30
at 2016-09-06T01:30
Related Posts
105年高普考題目
By Emma
at 2016-07-13T14:07
at 2016-07-13T14:07
台電 基電試題求解
By Zenobia
at 2016-07-13T12:34
at 2016-07-13T12:34
律師 補習問題
By Joseph
at 2016-07-13T11:46
at 2016-07-13T11:46
請教公文的受文者?
By Lauren
at 2016-07-13T11:40
at 2016-07-13T11:40
高考選擇題答案
By Faithe
at 2016-07-13T10:55
at 2016-07-13T10:55