首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
执行下面程序时,若输入1、-5、6,则输出结果为( )。 # include <stdio.h> # include <math.h> # define disc(a,b,c) b*b-4*a*c main()
执行下面程序时,若输入1、-5、6,则输出结果为( )。 # include <stdio.h> # include <math.h> # define disc(a,b,c) b*b-4*a*c main()
admin
2010-01-10
15
问题
执行下面程序时,若输入1、-5、6,则输出结果为( )。 # include <stdio.h> # include <math.h> # define disc(a,b,c) b*b-4*a*c main() { float x1,x2; int a,b,c; scanf("%d,%d,%d",&a,&b,&c); x1=(-b+sqrt(disc(a,b,c)))/(2*a); x2=(-b-sqrt(disc(a,b,c)))/(2*a); printf("%5.1f.%5.1f",x1,x2); }
选项
A、3,2
B、3.0,2.0
C、-3,-2
D、程序出错
答案
2
解析
本题是使用带参数的宏来求解一元二次方程的两个根。表达式x1=(-b+sqrt(disc(a,b,c)))/(2*a)宏展开后为: x1=(-b+sqrt(b*b-4*a*c))/(2*a)=(5+sqrt(25-24))/2=6/2=3。表达式x2=(-b-sqrt(disc(a,b,c)))/(2*a)宏展开后为: x2=(-b-sqrt(b*b-4*a*c))/(2*a)=(5-sqrt(25-24))/2=4/2=2。所以程序输出结果为3.0,2.0,应该选择B。
转载请注明原文地址:https://kaotiyun.com/show/ohWp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
能够将组合框Combol中最后一个数据项删除的语句为
以下关于多窗体的叙述中,正确的是
某带链栈的初始状态为top=bottom=NULL,经过一系列正常的入栈与退栈操作后,top=bottom=20。该栈中的元素个数为()。
在窗体上画一个命令按钮和一个文本框(名称分别为Command1和Text1),并把窗体的KeyPreview属性设置为True.,然后编写如下代码:DimSaveAllAsStringPrivateSu
下面可以识别功能键F1的事件是
窗体上有一个名称为Optionl的单选按钮数组,程序运行时,当单击某个单选按钮时,会调用下面的事件过程PrivateSubOptionl_Click(IndexAsInteger)EndSub下面关于此
假定有以下循环结构:DoUntil条件表达式循环体Loop则以下正确的描述是()。
下列有语法错误的赋值语句是( )。
随机试题
氧疗过程中需评估哪些状况,以判断用氧效果:
安静时,产热最多的器官是()。
下列说法中属于法的普遍性的含义的有()。
()是商业银行监管的首要环节,是保障银行机构稳健运行和金融体系安全的重要基础。
检查到的有不合格产品的建材企业占全国监督企业总数的百分比为:()检查到的有不合格产品企业的个数是:()
商品的价值
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中有整数栈类IntList、顺序栈类SeqList和链接栈类LinkList的定义。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:
A、Itwascreatedmainlyforscientificresearch.B、Itworksbetterinfineweatherconditions.C、Itmustbelocatedonatleast
TopicALetterofConsolationForthispart,youareallowed30minutestowritealettertoconsoleyourfriendwhosefamilyha
在21世纪初,我国出现了免费的地铁报(subwaynewspaper)。北京、上海、广州等大城市都有自己的地铁报。这些报纸通常在上班高峰期时在地铁站里发放。越来越多的人因为这些地铁报而重拾文字阅读的习惯。地铁报之所以受欢迎是因为它们非常了解受众读者(ta
最新回复
(
0
)