{"action":"created","issue":{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/16","labels_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/16/comments","events_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/16/events","html_url":"https://github.com/wujr5/c-and-cpp-language-learning/issues/16","id":114476213,"number":16,"title":"软件：week6 理论题（2015-11-2 实验课结束提交）","user":{"login":"ghostbody","id":8371330,"avatar_url":"https://avatars.githubusercontent.com/u/8371330?v=3","gravatar_id":"","url":"https://api.github.com/users/ghostbody","html_url":"https://github.com/ghostbody","followers_url":"https://api.github.com/users/ghostbody/followers","following_url":"https://api.github.com/users/ghostbody/following{/other_user}","gists_url":"https://api.github.com/users/ghostbody/gists{/gist_id}","starred_url":"https://api.github.com/users/ghostbody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghostbody/subscriptions","organizations_url":"https://api.github.com/users/ghostbody/orgs","repos_url":"https://api.github.com/users/ghostbody/repos","events_url":"https://api.github.com/users/ghostbody/events{/privacy}","received_events_url":"https://api.github.com/users/ghostbody/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/labels/%E8%BD%AF%E4%BB%B6%E7%8F%AD","name":"软件班","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-11-01T15:38:30Z","updated_at":"2015-11-06T13:18:59Z","closed_at":null,"body":"**1. What's the output of the following program:**\r\n```c\r\n#include <stdio.h>\r\nint main() {\r\n\tint n = 1, m = 4;\r\n\twhile(n = 1) {\r\n\t\tm--;\r\n\t\tn--;\r\n\t}\r\n\tprintf(\"%d %d\\n\", n, m);\r\n\treturn 0;\r\n}\r\n```\r\nA. 1 -1<br />\r\nB. 1 0<br />\r\nC. Dead Loop<br />\r\nD. 0 0<br />\r\n\r\n**2.What's the output of the following program:**\r\n```c\r\n#include<stdio.h>\r\nint main() {\r\n\tint a=4,b=8,c=5;\r\n\tint d1,d2,d3,d4;\r\n\td1=(a<b)||(++a==5)||(c>b--);\r\n\tprintf(\"d1=%d,a=%d,b=%d,c=%d\\n\",d1,a,b,c);\r\n\td2=(a>b)&&(++a==5)||(c>b--);\r\n\tprintf(\"d2=%d,a=%d,b=%d,c=%d\\n\",d2,a,b,c);\r\n\td3=(a<b)||(++a==5)&&(c>b--);\r\n\tprintf(\"d3=%d,a=%d,b=%d,c=%d\\n\",d3,a,b,c);\r\n\td4=(a>b)&&(++a==5)&&(c>b--);\r\n\tprintf(\"d4=%d,a=%d,b=%d,c=%d\\n\",d4,a,b,c);\r\n\treturn 0;\r\n}\r\n```\r\nA.\r\nd1=1,a=5,b=7,c=5\r\nd2=0,a=6,b=6,c=5\r\nd3=0,a=7,b=5,c=5\r\nd4=1,a=8,b=6,c=5\r\n<br />\r\nB.\r\nd1=1,a=5,b=7,c=5\r\nd2=1,a=6,b=6,c=5\r\nd3=1,a=7,b=5,c=5\r\nd4=0,a=8,b=6,c=5\r\n<br />\r\nC.\r\nd1=1,a=4,b=8,c=5\r\nd2=0,a=4,b=7,c=5\r\nd3=1,a=4,b=7,c=5\r\nd4=0,a=4,b=7,c=5\r\n<br />\r\nD. Compile error\r\n<br />\r\n<br />\r\n**3.What's the output of the following program:**\r\n```c\r\n#include<stdio.h>\r\nint main() {\r\n\tint a = 2, b = 3, c = 4;\r\n\tprintf(\"%d %d\",c > b > a, c < b < a);\r\n\treturn 0;\r\n}\r\n```\r\nA. 0 0<br />\r\nB. 0 1<br />\r\nC. 1 0<br />\r\nD. 1 1<br />\r\n\r\n\r\n**4.What's the output of the following program:**\r\n```c\r\n#include<stdio.h>\r\nint main() {\r\n\tint a = 3, b = 4, c = 5;\r\n\tint d = (a + b) + c - 1 && b + c / 2;\r\n\tprintf(\"%d\\n\", d);\r\n\treturn 0;\r\n}\r\n```\r\nA. 13<br />\r\nB. 1<br />\r\nC. 3<br />\r\nD. Compile error<br />\r\n\r\n\r\n**5.What's the output of the following program:**\r\n```c\r\n#include<stdio.h>\r\nint main() {\r\n\tfloat x = 2.5, y = 4.7;\r\n\tint a = 7;\r\n\tprintf(\"%.1f\\n\", x+a%3*(int)(x+y)%2/4);\r\n\treturn 0;\r\n}\r\n```\r\nA. 2.5<br />\r\nB. error: invalid operands to binary %<br />\r\nC. 0.0<br />\r\nD. 1.2<br />\r\n\r\n**6.Expression `!x||a==b` is Equivalent to**\r\nA. `!((x||a)==b)`<br />\r\nB. `!(x||y)==b`<br />\r\nC.` !(x||(a==b))`<br />\r\nD.` (!x)||(a==b)`<br />\r\n\r\n**7.What's the output of the following program:**\r\n```c\r\n#include<stdio.h>\r\nint main() {\r\n\tint i = -2;\r\n\tint n = ++i == 0 ? 99 : (i == -1 ? 11 : 22);\r\n\tprintf(\"%d\\n\",  n);\r\n\treturn 0;\r\n}\r\n```\r\nA.22<br />\r\nB.Compile error<br />\r\nC.0<br />\r\nD.11<br />\r\n\r\n\r\n**8.What's the output of the following program:**\r\n```c\r\n#include<stdio.h>\r\nint main() {\r\n    int x = 0, y = 0;\r\n    switch(x) {\r\n    \tx++;\r\n      y = 2;\r\n      case(0):\r\n      \tprintf(\"%d\\n\", y--);\r\n      \tbreak;\r\n      case(1):\r\n      \tprintf(\"%d\\n\", ++y);\r\n      \tbreak;\r\n   }\r\n}\r\n```\r\nA. 0<br />\r\nB. 2<br />\r\nC. 3<br />\r\nD. -1<br />\r\n\r\n**9.What's the output of the following program:**\r\n```c\r\n#include <stdio.h>\r\nint main() {\r\n    int number = 10;\r\n    printf(\"%d %d %d %d\\n\", number, number++, number--, --number);\r\n    return 0;\r\n}\r\n```\r\nA. 10 10 11 9<br />\r\nB. 10 11 10 10<br />\r\nC. 9 8 9 9<br />\r\nD. 10 11 10 9<br />\r\n\r\n\r\n**10.What's the output of the following program:**\r\n```c\r\nint main() {\r\n\tint a = 21, b = 11;\r\n\tprintf(\"%d\\n\", (--a+b, --b+a));\r\n}\r\n```\r\nA.30<br />\r\nB.31<br />\r\nC.32<br />\r\nD.33<br />\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/comments/154406982","html_url":"https://github.com/wujr5/c-and-cpp-language-learning/issues/16#issuecomment-154406982","issue_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/16","id":154406982,"user":{"login":"inkblack","id":15642591,"avatar_url":"https://avatars.githubusercontent.com/u/15642591?v=3","gravatar_id":"","url":"https://api.github.com/users/inkblack","html_url":"https://github.com/inkblack","followers_url":"https://api.github.com/users/inkblack/followers","following_url":"https://api.github.com/users/inkblack/following{/other_user}","gists_url":"https://api.github.com/users/inkblack/gists{/gist_id}","starred_url":"https://api.github.com/users/inkblack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inkblack/subscriptions","organizations_url":"https://api.github.com/users/inkblack/orgs","repos_url":"https://api.github.com/users/inkblack/repos","events_url":"https://api.github.com/users/inkblack/events{/privacy}","received_events_url":"https://api.github.com/users/inkblack/received_events","type":"User","site_admin":false},"created_at":"2015-11-06T13:18:59Z","updated_at":"2015-11-06T13:18:59Z","body":"仍然不懂第九题【躺倒，不过第十题按照逗号运算符好像是得30，但是我并不知道栈……这个算是 蒙的对吗"}}