C语言二级 选择题求助

\u6c42C\u8bed\u8a00\u4e8c\u7ea7\u9009\u62e9\u9898\u524d\u5341\u9898\u77e5\u8bc6\u70b9

\u9009\u62e9\u5171\u8ba135\u9053 \u5176\u4e2d\u524d10\u9053\u662f\u516c\u5171\u57fa\u7840\u77e5\u8bc6\uff0c\u540e15\u9053\u662fc\u8bed\u8a00\u77e5\u8bc6
\u586b\u7a7a\u5171\u8ba115\u4e2a\u7a7a \u5176\u4e2d\u524d5\u4e2a\u662f\u516c\u5171\u57fa\u7840\u77e5\u8bc6\uff0c\u540e10\u4e2a\u662fc\u8bed\u8a00\u77e5\u8bc6
\u603b\u8ba150\u9898\uff0c\u6bcf\u98982\u5206\uff0c\u516c\u5171\u57fa\u784030\u5206\uff0cc\u8bed\u8a0070\u5206
\uff081\uff09\u524d\u9762\u7684\u9009\u62e9\u9898\u662f\u57fa\u7840\u77e5\u8bc6 \uff0c\u4e8c\u7ea7C\u8bed\u8a00\u77e5\u8bc6\u70b9\u5206\u5e03\u5305\u62ec\uff1a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5 \u3001\u7a0b\u5e8f\u8bbe\u8ba1\u57fa\u78401\uff0c\u8f6f\u4ef6\u5de5\u7a0b\u57fa\u7840\uff0c\u6570\u636e\u5e93\u8bbe\u8ba1\u57fa\u7840\uff0cC\u7a0b\u5e8f\u8bbe\u8ba1\u7684\u521d\u6b65\u77e5\u8bc6\uff0c\u987a\u5e8f\u7ed3\u6784\u8bbe\u8ba1\uff0c\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\u3002\u5faa\u73af\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff0c\u51fd\u6570\uff0c\u6307\u9488\u4e0e\u6570\u7ec4\uff0c\u7f16\u8bd1\u4e0e\u5904\u7406\u4e0e\u52a8\u6001\u5b58\u50a8\u5206\u914d\uff0c\u7ed3\u6784\u4f53\u4e0e\u5171\u7528\u4f53\uff09\uff0c\u4f4d\u8fd0\u7b97\uff0c\u6587\u4ef6\u64cd\u4f5c\uff0c\u8003\u67e5\u7684\u77e5\u8bc6\u70b9\u6bd4\u8f83\u7ec6\u81f4\uff0c\u4f8b\u5982PAD\u56fe\uff0c\u7ebf\u6027\u7ed3\u6784\u4e0e\u975e\u7ebf\u6027\u7ed3\u6784\u3001\u7a0b\u5e8f\u7684\u7f16\u8bd1\u4e0e\u89e3\u91ca\u3001if\u8bed\u53e5\u7684\u903b\u8f91\u5224\u65ad\u3001C\u7a0b\u5e8f\u7684\u6267\u884c\u8fc7\u7a0b\u3001\u683c\u5f0f\u63a7\u5236\u3001\u5faa\u73af\u6267\u884c\u6b21\u6570\uff0c\u6307\u9488\u4e0e\u6570\u7ec4\u7684\u5e94\u7528\uff0cif\u8bed\u53e5\u7684\u5d4c\u5957\uff0c\u6570\u7ec4\u7684\u5e94\u7528\uff0c\u9759\u6001\u5c40\u90e8\u53d8\u91cf\uff0c\u9884\u5904\u7406\uff0c\u7ed3\u6784\u4f53\u6307\u9488\u53d8\u91cf\uff0c\u4f4d\u8fd0\u7b97\u7b49\u7b49\u3002
\uff082\uff09\u8003\u8bd5\u7684\u5e38\u89c1\u77e5\u8bc6\u70b9\uff1a\u4f8b\u5982\u57fa\u672c\u7684\u6570\u636e\u7ed3\u6784\uff0c\u6570\u636e\u5e93\u7684\u57fa\u672c\u6982\u5ff5\uff0c\u8f6f\u4ef6\u751f\u547d\u5468\u671f\u6982\u5ff5\uff0c\u67e5\u627e\u548c\u6392\u5e8f\u7b97\u6cd5\u3002\u7a0b\u5e8f\u8bbe\u8ba1\u7684\u65b9\u6cd5\u4e0e\u98ce\u683c\uff0c\u7ed3\u6784\u5316\u7684\u5206\u6790\u65b9\u6cd5\uff0c\u6570\u636e\u6d41\u56fe\uff0c\u6570\u636e\u5b57\u5178\u548c\u8f6f\u4ef6\u9700\u6c42\u89c4\u683c\u8bf4\u660e\u4e66\uff0c\u7ed3\u6784\u5316\u5206\u6790\u65b9\u6cd5\uff0c\u603b\u4f53\u8bbe\u8ba1\u548c\u8be6\u7ec6\u8bbe\u8ba1\uff0c\u8f6f\u4ef6\u6d4b\u8bd5\uff0c\u5173\u7cfb\u8fd0\u7b97\uff0cC\u7a0b\u5e8f\u7684\u6784\u6210\u4e0e\u683c\u5f0f\uff0c\u5e38\u7528\u6570\u636e\u7c7b\u578b\uff0c\u8fd0\u7b97\u7b26\u548c\u8868\u8fbe\u5f0f\uff0c\u8f93\u5165\u8f93\u51fa\u51fd\u6570\uff0cif\u8bed\u53e5\u548cswitch\u8bed\u53e5\uff0cwhile,for\u8bed\u53e5\u7684\u4f7f\u7528\uff0c\u51fd\u6570\u7684\u57fa\u672c\u6982\u5ff5\uff0c\u51fd\u6570\u7684\u8fd4\u56de\u503c\uff0c\u53c2\u6570\u4f20\u9012\u4e2d\u7684\u4f20\u503c\u65b9\u6cd5\u4e0e\u4f20\u5730\u5740\u65b9\u6cd5\uff0c\u9759\u6001\u5b58\u50a8\u53d8\u91cf\uff0c\u6307\u9488\u4e0e\u6570\u7ec4\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u5b57\u7b26\u4e32\u7684\u5e94\u7528\uff0c\u6307\u9488\u4e0e\u6570\u7ec4\u7684\u5173\u7cfb\uff0c\u9884\u5904\u7406\u4e0e\u52a8\u6001\u5b58\u50a8\u5206\u914d\uff0c\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49\u548c\u53d8\u91cf\u7684\u5f15\u7528\uff0c\u6587\u4ef6\u64cd\u4f5c\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\u4e0d\u8981\u4ee5\u4e3aC\u8bed\u8a00\u5c31\u662f\u5355\u7eaf\u7684\u8003C\u8bed\u8a00\u7a0b\u5e8f\uff0c\u4e5f\u8981\u6ce8\u610f\u5173\u4e8e\u7f16\u7a0b\u7684\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\u548c\u8ba1\u7b97\u673a\u7684\u77e5\u8bc6\uff0c\u5bf9\u91cc\u9762\u7684\u7a0b\u5e8f\u9898\u8981\u7279\u522b\u7684\u5c0f\u5fc3\u624d\u662f\uff0c\u505a\u9898\u7684\u65f6\u5019\u8981\u7528\u7b14\u753b\u51fa\u6765\u5177\u4f53\u7684\u6b65\u9aa4\uff0c\u8fd9\u6837\u907f\u514d\u51fa\u9519\uff0c\u53cd\u6b63\u5c0f\u5fc3\u5e94\u5bf9\u4fbf\u662f

A\u7684\u610f\u601d\u662f\u53d6n\u7684\u5730\u5740\u8d4b\u7ed9\u6307\u9488p \uff0c*p\u8868\u793a\u53d6\u6307\u9488p\u91cc\u7684\u53d8\u91cf\u503c\uff0c\u6b63\u786e\u662fp=&n;
B\u540c\u7406\uff0c\u8f93\u51fa\u7684\u662f\u53d8\u91cf\u503c\uff0c\u800c\u4e0d\u662f\u5730\u5740\uff0c\u6b63\u786e\u662fprintf\uff08"%d\n\u201d,*p\uff09;
C\u683c\u5f0f\u8f93\u5165\u51fd\u6570scanf\u540e\u9762\u53c2\u6570\u662f\u53d6\u5730\u5740\u503c\uff0c\u4e4d\u770b&p\u597d\u50cf\u5bf9\uff0c\u4f46\u662f\u522b\u5fd8\u4e86p\u662f\u6307\u9488\u53d8\u91cf\uff0c\u672c\u8eab\u4f5c\u7528\u5c31\u662f\u4fdd\u5b58\u5730\u5740\uff0c\u6240\u4ee5\u6b63\u786e\u662fscanf\uff08"%d",p\uff09;

\u7b2c\u4e00\u9898\u561b\uff0cif\uff08a=1\uff09b=1\uff1b\u540e\u9762\u6709\u4e00\u4e2a\u5206\u53f7\uff0c\u770b\u5230\u4e86\u5417\uff0c\u8fd9\u6837if\u8bed\u53e5\u5c31\u7ed3\u675f\u4e86\uff0c\u6240\u4ee5\u540e\u9762\u8fd8\u52a0else\u8bed\u53e5\u5c31\u4f1a\u51fa\u9519\u54af

选B

n统计数组中大于等于0小于等于9数字的个数.

s[i]!=0,就是说遇到\0结束.则统计了"012"就是3个

而如果是s[i]!=1的话.查看ascall码表得1的字符值为SOH

如此程序就永远不会停止-..就会卡了..

如果是012xy08s34f4w2,这样子的话,会一直统计到最后.

那结果会变为9

系统会自动在最后一个字符后面加一个\0这是你看不到的.作为字符结束符

char数组遇到\0结束。也就是说s中实际上只存了"012xy"。
for循环是就算数组中数字的个数,所以答案是B:3

juzizj说得对,如果把s[i]!=0改为s[i]!='0'的话,s[i]!='0'的意思是遇到s[]中的第一个字符0即结束,没有进行for循环,所以没有n++,结果输出n为0。

答案是B。

for循环中n的意思是,数组中大于等于0小于等于9数字的个数。但是S[i]!=0,就是说遇到\0结束。

扩展阅读:扫一扫出答案 ... 免费拍照答题一秒出答案 ... 二级c语言免费题库 ... 二级证书哪个最好考 ... c++搜题专用软件 ... 编程必背100个代码 ... c++入门程序代码 ... c语言代码生成器 ... c++编程跳动爱心代码 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网