作者mafiataiki (辉 ^.< 啾咪)
看板NCHU-ENVE102
标题[讨论] 计盖第一题
时间Mon Oct 25 14:22:29 2010
f1=function(a,b,c)
{
cat(a," x^2+",b,"x+",c,"\n")
if (b^2-4*a*c >0){
x1= (-b+sqrt(b^2-4*a*c)) / (2*a)
x2= (-b-sqrt(b^2-4*a*c)) / (2*a)
print("2实根")
print(x1)
print(x2)
}
else if (b^2-4*a*c ==0) {
x=-b/(2*a)
print("2重根")
print(x)
}
else if (b^2-4*a*c <0) {
print("2虚根")
cat( (-b)/(2*a),"+",abs(b^2-4*a*c)^0.5,"i","\n")
cat( (-b)/(2*a),"-",abs(b^2-4*a*c)^0.5,"i","\n")
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.120.151.157
1F:推 wade03503:原PO救了众生 10/25 14:24
2F:推 andy0910:刚学弟有人说 那麽强怎麽还被当 10/25 14:31
3F:→ mafiataiki:e04 我也很想问为什麽我被当\ 10/25 14:31
4F:推 flyfly01:怎麽感觉以前写过... 10/25 14:42