题目内容 (请给出正确答案)
[主观题]

有以下程序: #include<stdio.h> main() {int a[5]={1,2,3,4,5),b[5]={0,2,1,3,o},i,s=

0; for(i=o;i<5;i++)s=s+a[b[i]]; printf(”%d\n”,s); } 程序运行后的输出结果是()。

A.6

B.10

C.11

D.15

答案
C
本题考查数组的使用。本题定义了两个数组,注意数组的下标是从0开始的,进行第1次for循环:当i=0时,b[0]为数组b中第l个元素,结果为0,那么a[0]也是数组a中第l个元素,结果为1,所以S的值为1。第2次循环:i此时自加为l,b[1]为数组的第2个元素,值为2,所以可求出a[2](数组中的第3个元素)的值为3,s=s+3,所以S的值为4。进入第3次for循环,依此类推,第3次for循环结束时s的值为6。第4次for循环,s的值变为l0。第5次for循环时,此时i的值为4,s的值变为ll,i=5不符合题意,所以跳出循环,输出结果,所以本题答案为C。
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“有以下程序: #include<stdio.h> main(…”相关的问题

第1题

设文件test.txt中原已写入字符串Begin,执行以下程序后,文件中的内容为【 15 】 。#include <stdi

设文件test.txt中原已写入字符串Begin,执行以下程序后,文件中的内容为【 15 】 。

#include <stdio.h>

main()

{ FILE *fp;

fp= fopen("test.txt”, ”w+”);

fputs("test",fp);

fclose(fp);

}

点击查看答案

第2题

以下程序中函数setup的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址:# include<stdi

以下程序中函数setup的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址: # include<stdio. h> # include<string. h> char * scmp(char * s1, char * s2) { if(strcmp(s1, s2)<0) return(s1); else return(s2); } main() { int i; char string[20], str[3][20]; for(i=0; i<3; i++)gets(str[i]); strcpy(string, scmp(str[0], str[1])); strcpy(string, scmp(string, str[2])); printf("% s\n", string); } 若运行时依次输入:abcd、abba和abc3个字符串,则输出结果为______。

A.abcd

B.abba

C.abc

D.abca

点击查看答案

第3题

有以下程序:# include < iostream>执行这个程序,输出结果是( )。
有以下程序:# include< iostream>执行这个程序,输出结果是()。

有以下程序:

# include< iostream>

有以下程序:# include 执行这个程序,输出结果是()。有以下程序:# include 执行这

执行这个程序,输出结果是()。

有以下程序:# include 执行这个程序,输出结果是()。有以下程序:# include 执行这

点击查看答案

第4题

有以下程序以下程序运行时输出到屏幕的结果是 include void main();}
点击查看答案

第5题

有以下程序()

A.#include

B.0

C.-1

D.1

E.7

点击查看答案

第6题

有以下程序()

A.#include

B.abcdef

C.ABCDEF

D.aBcDeF

E.AbCdEf

点击查看答案

第7题

有以下程序: #include void fun()

A.321678

B.876543

C.1098765

D.345678

点击查看答案

第8题

有以下程序#include <stdio.h>#include <string.h>main(){ printf("%d\n",strlen (

有以下程序

#include <stdio.h>

#include <string.h>

main()

{ printf("%d\n",strlen ("ATS\n012\1") ); }

程序运行后的输出结果是

A)3

B)8

C)4

D)9

点击查看答案

第9题

有以下程序:#include <iostream>#include <fstream>using namespace std;int main (){ ofstream

有以下程序: #include <iostream> #include <fstream> using namespace std; int main () { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);

A.程序编译时出错

B.abc#

C.abc

D.#

点击查看答案

第10题

有以下程序:include<stdio.h>include<strin9.h>main(){printf{"%d\n",s

有以下程序:

include<stdio.h>

include<strin9.h>

main()

{printf{"%d\n",strlen("%d\n",strlen("ATS\n012\|"));}

程序运行后的输出结果是()。

A.3

B.8

C.4

D.9

点击查看答案
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
温馨提示
每个试题只能免费做一次,如需多次做题,请购买搜题卡
立即购买
稍后再说
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
赏学吧
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反赏学吧购买须知被冻结。您可在“赏学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
赏学吧
点击打开微信