首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include <stdio.h> int m1(int x, int y ) { if( x<= y ) return 2*x+1; else return y; } int m2(int x, int y )
有以下程序 #include <stdio.h> int m1(int x, int y ) { if( x<= y ) return 2*x+1; else return y; } int m2(int x, int y )
admin
2021-04-28
20
问题
有以下程序
#include <stdio.h>
int m1(int x, int y )
{ if( x<= y ) return 2*x+1;
else return y;
}
int m2(int x, int y )
{ if( x<= y ) return 2*y+1;
else return x;
}
main()
{ int i, t1=10, t2=0;
for( i=1; i<=4; i++ )
{ t1=m1( i,t1 ); t2=m2( i,t2 ); }
printf("t1=%d t2=%d \n", t1, t2 );
}
程序运行后的输出结果是
选项
A、t1=9 t2=4
B、t1=4 t2=9
C、t1=9 t2=9
D、t1=1 t2=4
答案
A
解析
函数m1(x,y),若x<y,返回2*x+1,否则返回y, 函数m2(x,y),若x<=y,返回2*y+1,否则返回x,for循环对t1=m1(i,t1),执行4次,可知答案为9,t2=m2(i,t2), 执行4次,可知答案为4,因此答案为A选项。
转载请注明原文地址:https://kaotiyun.com/show/tPtp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序段intj;floaty;charname[50];scanf(’’%2d%f%s’’,&j,&y,name);当执行上述程序段,从键盘上输入555667777abc后,y的值为
在源程序的开始处加上#include<stdio.h>进行文件引用的原因,以下叙述正确的是()。
一棵二叉树中共有80个叶子结点与70个度为1的结点,则该二叉树中的总结点数为()。
读取二进制文件的函数调用形式为:fread(buffer,size,count,fp);其中buffer代表的是
一个栈的初始状态为空,现将元素A、B、C、D、E依次入栈,然后依次退栈三次,并将退栈的三个元素依次入队(原队列为空),最后将队列中的元素全部退出。则元素退队的顺序为
若a是数值类型,则逻辑表达式(a==1)||(a!=1)的值是
以下程序中函数sort的功能是对a数组中的数据进行由大到小的排序voidsort(inta[],intn){inti,j,t;for(i=0;i<n-1;i++)for(j=i+1;j<n;j++)
有两个关系R和T如下图所示:则由关系R得到关系T的运算是()。
设顺序表的长度为n。下列排序方法中,最坏情况下比较次数小于n(n-1)/2的是
对序线性表(23,29,34,55,60,70,78)用二分法查找值为60的元素时,需要比较次数为()。
随机试题
A、硝苯地平B、硝酸异山梨酯C、硝普钠D、普萘洛尔E、卡托普利可用于稳定型心绞痛治疗的药物是
当三叉神经第三支伴有舌神经痛时应注意加以鉴别的是
A、芡实B、椿皮C、赤石脂D、山茱萸E、覆盆子内服治虚汗不止的药是
A.气胸B.出血及血肿C.膈神经麻痹D.声音嘶哑E.全脊髓麻醉患者,男,48岁。行颈深丛阻滞麻醉,于左、右侧各注射0.25%的布比卡因与1%利多卡因混合液5ml,注完药后约8分钟,患者自感胸闷,气短,血压和SPO2正常,面罩吸氧1小时后症状减轻
国有土地所有者代表依法将国家土地所有权的部分权能让与土地使用者,()对土地依法享有收益权,并保有最终处分权。
某海滨城市一建筑工程,16层施工时正遇台风多雨季节,为了保质保量完成施工任务,项目部制订了安全文明施工保障措施,落实了防火措施,主要部位设置了安全警示标志牌,并加强了对高空作业人员的安全教育。安全员在检查时,发现存在以下问题:(1)下雨天,地下室用
在DWDM系统中,将不同波长的光信号耦合在一起传送到一根光纤里的网元是()。
铁路建设项目实行施工(工程)总承包的,由()对施工现场安全生产负总责。
一项对某高校教员的健康调查表明,80%的胃溃疡病患者都有夜间工作的习惯。因此,夜间工作易造成的植物神经功能紊乱是诱发胃溃疡病的重要原因。以下哪项如果为真,将严重削弱上述论证?
Theteacheragreedtothesuggestionthat_______________(给学生们两周时间来准备考试).
最新回复
(
0
)