菜鸟程序改错# include # include int main(void){ int a = 1;int b =

jiajun29892022-10-04 11:39:541条回答

菜鸟程序改错
# include
# include
int main(void)
{ int a = 1;
int b = 2;
int c = 1;
double delta;
double x1 ;
double x2 ;
int delta = b*b-4*a*c;
if ( delta > 0 )
{ x1= (-b + sqrt(delta)/(2*a);
x2= (-b - sqrt(delta)/(2*a);
printf ("该一元二次方程有两个解,x1 = %f,x2 = %fn",x1,x2);
}
else if ( delta == 0 )
x05{ x1=(-b)/(2*a);
x2 = x1 ;
x05x05printf ("该一元二次方程有唯一解,x1 = x2 = %fn",x1);
x05x05
x05x05}
else
x05{ printf ("无解"n",x1); }
x05return 0;
}
-------------------Configuration:Cpp2 - Win32 Debug--------------------
Compiling...
Cpp2.cpp
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(12) :error C2371:'delta' :redefinition; different basic types
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(9) :see declaration of 'delta'
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(15) :error C2143:syntax error :missing ')' before ';'
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(16) :error C2143:syntax error :missing ')' before ';'
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(26) :error C2017:illegal escape sequence
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(26) :error C2001:newline in constant
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(26) :error C2146:syntax error :missing ')' before identifier 'n'
C:Documents and SettingsAdministrator桌面新建文件夹Cpp2.cpp(30) :fatal error C1004:unexpected end of file found
执行 cl.exe 时出错.
Cpp2.obj - 1 error(s),0 warning(s)

已提交,审核后显示!提交回复

共1条回复
娃哈哈m94 共回答了23个问题 | 采纳率95.7%
编译的问题这样改就没了.


# include
# include

int main(void)
{int a = 1;
int b = 2;
int c = 1;
double delta = b*b-4*a*c;
double x1 ;
double x2 ;
//int delta = b*b-4*a*c; // <== delta定义过了
if ( delta > 0 )
{x1= (-b + sqrt(delta))/(2*a); // <== 原来括号不配对
x2= (-b - sqrt(delta))/(2*a); // <== 原来括号不配对
printf ("该一元二次方程有两个解,x1 = %f, x2 = %fn",x1, x2);
}
else if ( delta == 0 )
{x1=(-b)/(2*a);
x2 = x1 ;
printf ("该一元二次方程有唯一解,x1 = x2 = %fn",x1);
}
else
{printf ("无解n",x1); } // <== 原来多一个双引号

return 0;
}


运行结果:


该一元二次方程有唯一解,x1 = x2 = -1.000000
1年前

相关推荐

英语菜鸟求解My sister is also a volunteer__this programScott got h
英语菜鸟求解
My sister is also a volunteer__this program
Scott got his report card__school yesterday
I think it is not a good idea__you to travel alone.
Mike's friend is good__reading and writing in English
Do you have a hard time__music?
Yes .can you help me?
That's all the children should stay in the classroom to do their homework.
iasgnaw1年前1
曹家健 共回答了18个问题 | 采纳率88.9%
in
at
for
at
of
菜鸟机器勿入!it is great deal easier to motivate employee in a gro
菜鸟机器勿入!
it is great deal easier to motivate employee in a growing organization than a declining one
更正:是It is a great deal............................
离开以后1231年前7
diiaojq 共回答了12个问题 | 采纳率75%
有发展(行情看涨)的企业(组织)比行情下滑的企业更容易激励雇员
新手菜鸟提问,怎么判断电压UAB正负.
新手菜鸟提问,怎么判断电压UAB正负.
假如测的AB两端电位,A点+10V,B点+5V.求UAB是多少,UBA是多少?UAB叫做A点到B点的电压,还是叫做A点到B点的电压.UAB=VB-VA,即电压UAB等于B点电位减A点电位,
天天快乐不难1年前1
kele0606 共回答了20个问题 | 采纳率70%
UAB=UA-UB UA>UB时,UAB>0为正,UA<UB时,UAB<0为负
UAB=UA-UB =10V-5V=5V UBA=-5V UAB叫做A点到B点的电势的差值,也称为电压.
你后面说的相反了
英语菜鸟求解He broke his arm playing basketball yesterday and was
英语菜鸟求解
He broke his arm playing basketball yesterday and was sent to hospital
我想问的是
1、前句arm和playing中间when he was 可以省略的吗?
2、sent to hospital 在hospital前是否可以加a或者the这类的冠词呢?
一烟1年前2
5开会可jh 共回答了15个问题 | 采纳率86.7%
可以省略的,因为主语是he 和从句是一样的.这叫独立主格.当从句和主句的逻辑主语一致的时候,则可以省略从句的逻辑主语.若从句是主动关系,则保留谓语ing形式.
不能加a 或the.去医院治疗或治疗不要加.在医院工作什么的可以加.
本人菜鸟,Look at our office assistant .is very hard-working
本人菜鸟,Look at our office assistant .is very hard-working
空出的地方该填什么we 还是they 还是he还是she
zuorubin1年前1
xxt9 共回答了22个问题 | 采纳率86.4%
由于系动词是is,故主语必须为单数,所以不选we或者they.
至于he还是she?我认为哪个都对,除非我们能够确定办公室助理是男的还是女的.
本人菜鸟,
松子1471年前6
xlqjlb 共回答了29个问题 | 采纳率86.2%
主语是句子陈述的对象,说明是谁或什么.表示句子说的是"什么人"或“什么事”.
谓语是对主语动作或状态的陈述或说明,指出“做什么”、“是什么”或“怎么样”.谓语动词的位置一般在主语之后.
宾语是动作、行为的对象,是动作的承受者.宾语由名词、代词、不定式或相当于名词的词、短语来担任.当然,也可以由一个句子来充当,称之为宾语从句,所以一个句子中不一定只有一个宾语.
菜鸟怎么翻译
从不问理由1年前4
jefferyhsu 共回答了22个问题 | 采纳率90.9%
玩过哪怕一天国外网游的都知道,菜鸟最正确的翻译是:noob
A "noob" is a person who is new or inexperienced in a subject,usually an online game.Noobs are usually annoying and excessively stupid.Do not confuse noobs with newbs,who are inexperienced players that tend to be more mature and strive to become better.
其他的什么newbie beginner等等,都是表达的新手的意思,指刚开始从事或参加某种活动或职业,而菜鸟noob强调的是水平太低,老手可能玩了很多年但是水平太差还是菜鸟,而新手可能刚刚玩却有pro的天赋而不是菜鸟.
ACCA F2 菜鸟提问A manufacturing company uses 28000 components at
ACCA F2 菜鸟提问
A manufacturing company uses 28000 components at an even rate during the year.Each order placed with the supplier of the components is for 1500 components which is the economic order quantity.The company holds a buffer inventory of 700 components.The annual cost of holding one component in inventory is 3.What is the total annual cost of holding inventory of the component
A 2250 B 3300 C 4350 D 4500
fancy_57_xu1年前1
zs49496585 共回答了21个问题 | 采纳率95.2%
一家工厂一年平均使用28000个部件.每次向供应商订货都是按最佳经济数量订购1500个部件.公司在剩下700个部件时就会向供应商采购.一个部件的储存成本是每年3元.问题:一年的存货贮藏(储存)成本是多少.
请看下面的图片,算准一年里储藏了多少数量就行了
首先700件是固定不变的其次每次采购的1500件,由于用量是平均的(even rate),所以使用状态是按线性减少,每次用到700件了,就再买1500件,所以一年内在仓库里的平均有1500/2=750件,就是图中这些三角形这样就可以得到,一年内的平均存货有700+750=1450件每件储藏成本3元,那么最终结果是1450*3=4350元答案选C那个开头的28000误导考生用的,在这道题里没用.
菜鸟勿进nearly all the streets are in straight lines,-------- fr
菜鸟勿进
nearly all the streets are in straight lines,-------- from east tp west.Those ---------run from north to south are called avenues
Arunning that B run who C running who Drun that
this is the case-------he's had all his money stolen
A when B where C that D on which
the artist will not paint people or animals but he will paint anying-----
Athat the little girl askss him Bthe little girl asks him to
Cfor the little girl to ask him Dwhat the little girl asks him
how did you get in touch with the travel agent,Robin?
oh,that's easy.I surfed the internet and then called one ------the telephone number is provided
A which B in which C of which D whose
纯粹名字1年前3
有刺的好鱼 共回答了13个问题 | 采纳率84.6%
A run是不及物动词,所以这里用现在分词; those 指streets,因此用 that
B case 后面接一个定语从句,从句里不缺主要成分,所以先行词(in) the case在句中做逻辑地点状语
B anything 后接了一个定语从句,排除答案C和D.ask him to 后省略了paint.不定式的省略要保留到to.
C the telephone number of the travel agent