首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序 #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
31
问题
有如下程序
#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://jikaoti.com/ti/L0kiFFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
医生诊疗费用的低下与药品加成的过高,共同形成了以药养医的现状。它保证了公共医院在数据上的收支平衡,却导致了“大处方”“新特贵药”“过度医疗”等现象的出现,让医生和患者都容易成为扭结的医疗制度及以其为轴的社会冲突的代偿者。2016年,患者魏则西的去世和医生陈
下列广告语不科学的是()。
下列科技发明与人物的对应关系,不正确的是()。
2019年12月17日,我国第一艘国产航母山东舰正式交付。下列关于山东舰的说法,错误的是()。
某学生某次数学测验的标准分为2.58,这说明全班同学中成绩在他以下的人数百分比是多少?如果标准分是-2.58,则全班同学中成绩在他以下的人数百分比是多少?()
某中学高三年级有三个班,高考前有一个免试保送升学名额,分别来自三个班的候选人的成绩如下:请选用不同的综合方法,帮助学校领导做出决策,决定保送对象,并评价其合理性。
我国实体法和程序法开始逐步分离始于()
对函数f(χ)(4-t)ln(1+t)dt().
在进行某学校教务管理系统的数据库设计时,数据库设计人员设计了如下几个关系模式:系(系号,系名),系号为主码学生(学号,姓名,所在系号),学号为主码课程(课程号,课程名,开课系号),课程号为主码选课(学号,课程号,选课时间),学号和课程号为主码开发
下图是DHCP客户机获取IP地址等配置信息时,使用Wireshark软件捕获报文中编号为26~29的4条报文,图中对编号为29的报文进行了解析。分析图中的信息并补全图中【11】~【15】处的信息。
随机试题
我国《收养法》中许多规定体现了有利于未成年人的抚养和成长的原则,比如()
阻塞性黄疸鉴别诊断的诊断方法有
对原产于与我国签订含有关税优惠条款的区域性贸易协定的国家或地区的进口货物,按最惠国税率征收关税。()(2013年)
根据个入股票期权所得的征税规定,员工行权时,从企业取得股票的实际购买价(施权价)低于购买日公平市场的差额,应计算缴纳个人所得税,其适用的应税所得项目为()。
中国工商银行私人银行的品牌宗旨是()。
平衡线法借助平衡线规定各生产环节的任务,并通过计算______与______的对比分析,及早发现影响作业计划完成的原因,尽量避免物流中断。
利用简便方法计算下列算式:
合同法:法律
设一汽车沿街道行驶,需要经过三个有红绿灯的路口,每个信号灯显示是相互独立的,且红绿灯显示时间相等,以X表示该汽车首次遇到红灯前已通过的路口个数,求X的分布.
Forthispart,youareallowed30minutestowriteashortessayentitledOnAcademicPlagiarism.Youshouldwriteatleast150
最新回复
(
0
)