作者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