首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序 #include <stdio.h> struct pair { int first, second; }; struct pair get_min_max(int* array, int len) { int i;
有如下程序 #include <stdio.h> struct pair { int first, second; }; struct pair get_min_max(int* array, int len) { int i;
admin
2019-07-25
27
问题
有如下程序
#include <stdio.h>
struct pair
{
int first, second;
};
struct pair get_min_max(int* array, int len)
{
int i;
struct pair res;
res.first = array[0];
res.second = array[0];
for (i=1; i<len; i++)
{
if (array
< res.first)
res.first = array
;
if (array
> res.second)
res.second = array
;
}
return res;
}
main( )
{
int array[6] = {19, 21, 3, 4};
struct pair min_max = get_min_max(array, 6);
printf("min=%d,max=%d\n", min_max.first, min_max.second);
}
程序运行后的输出结果是
选项
A、min=0,max=6
B、min=1,max=20
C、min=1,max=19
D、min=0,max=21
答案
D
解析
本题首先在main函数定义一个数组array,然后定义了一个结构变量min_max,min_max使用函数get_min_max的返回值初始化,函数get_min_max的功能就是将数组中的最小值和最大值取出来后分别赋值给结构变量min_max中的first,second两个整形变量,数组长度为6个单位,初始化4个数据,剩下2个默认为0,因此答案为D选项。
转载请注明原文地址:https://kaotiyun.com/show/VpID777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
阅读以下文字,回答下列问题。要处理好改革发展稳定的关系。坚持改革力度、发展速度和社会可承受度的统一,是我国改革开放和现代化事业之所以能够顺利推进的宝贵经验。________________。“天时不如地利,地利不如人和。”要打好改革攻坚战,就要在
下面四个单句,与例句的语法结构相同的是()。例:老师鼓励学生学好功课。
关于微波,下列说法正确的是()。
下列广告语不科学的是()。
下列科技发明与人物的对应关系,不正确的是()。
从洋务运动看中国近代化的特点。(西北大学2013年中国史真题)
在随机区组实验设计中,总平方和可以被分解为()
赞科夫认为,有的学生“按学习成绩来说是属于优等生,但是在发展方面却处于中等甚至更低的水平”,因此,教师要遵循
设函数U=f(χz,yz,χ)的所有二阶偏导数都连续,则=().
如下图所示,函数f(x)是以2为周期的连续周期函数,它在[0,2]上的图形为分段直线.g(x)是线性函数,则_______
随机试题
输入储存久的库存血易引起
根尖周病治疗原则应是
下列选项中,属于评标专家的权利是()。
【背景资料】某城市给水工程项目,总承包商将给水管道工程分包给具有相应资质能力的承包商。该分包商在施工中的一些情况如下:情况一:大型球墨铸铁管采用原土地基。情况二:球墨铸铁管接口采用人工推入式接口。情况三:承插式铸铁管接口材料使用的石棉必须是4F有
火柴受到摩擦而着火的现象,属于()。
课堂教学要紧密联系学生的(),从学生的经验和已有知识出发,创设有助于学生自主学习、合作交流的情境。
甲公司与乙公司订立买卖合同,双方约定,甲公司应于2012年9月1日向乙公司交付货物,乙公司应于9月8日向甲公司交付货款。8月底,甲公司发现乙公司经营状况严重恶化,并有确切证据可以证明。9月1日届至,甲公司()。
计算下列二重积分:设D:|x|≤1,|y|≤1,求|y-x|dxdy.
RS-232C是(11)之间的接口标准,它是(12)协议,其机械特性规定RS-232C的D型连接器有(13)个插脚,使用RS-232C接口进行数据通信时,至少需用的信号线有(14)。当Modem和计算机相连时,按此标准需要连接的最少线数是(15)。
Although,somestudentsgraduatefromhighschool,theyarevirtuallyilliterate______writingabusinessletter.
最新回复
(
0
)