C/ C++,a006: 一元二次方程式@0判
FB2:http://gg.gg/TedLeeMicrobitFB/
URL2:http://gg.gg/TedLeeMicrobit/
Line:ted2016.kpvs
Email:Lct4246@gmail.com
FB1:http://gg.gg/TedLeeFB/
Blog:http://gg.gg/TedLeeBlog/
URL1:http://gg.gg/TedLeeURL/
Jun. 23, 2020
問題解決(Problem Solving)之逻輯思維 =
心法: 程式設計哲思(Philosophical Thinking for Programming) +
技法:程式設計工法(Skills for Programming)
解析:
//http://siro.moe.edu.tw/teach/index.php?n=0&m=0&cmd=content&sb=3&v=3&p=437
#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
int a=0, b=0, c=0;
float D=0;
cin>>a>>b>>c;
D=b*b-4*a*c;
if (D>0)
cout << "Two different roots x1=" << (-b+sqrt(D))/(2*a) << " , " << "x2=" << (-b-sqrt(D))/(2*a); //第一次作時打成2*a,忘了()
if (D<0 span="">0>
cout << "No real root";
if (D==0)
cout << "Two same roots x=" << (-b+sqrt(D))/(2*a);
return 0;
}
FB2:http://gg.gg/TedLeeMicrobitFB/
URL2:http://gg.gg/TedLeeMicrobit/
Line:ted2016.kpvs
Email:Lct4246@gmail.com
FB1:http://gg.gg/TedLeeFB/
Blog:http://gg.gg/TedLeeBlog/
URL1:http://gg.gg/TedLeeURL/
URL1:http://gg.gg/TedLeeURL/
Jun. 23, 2020
問題解決(Problem Solving)之逻輯思維 =
心法: 程式設計哲思(Philosophical Thinking for Programming) +
技法:程式設計工法(Skills for Programming)
解析:
//http://siro.moe.edu.tw/teach/index.php?n=0&m=0&cmd=content&sb=3&v=3&p=437
int main(void) {
int a=0, b=0, c=0;
float D=0;
cin>>a>>b>>c;
D=b*b-4*a*c;
if (D>0)
cout << "Two different roots x1=" << (-b+sqrt(D))/(2*a) << " , " << "x2=" << (-b-sqrt(D))/(2*a); //第一次作時打成2*a,忘了()
if (D<0 span="">0>
cout << "No real root";
if (D==0)
cout << "Two same roots x=" << (-b+sqrt(D))/(2*a);
return 0;
}
#include <iostream>
#include <math.h>
using namespace std;
int a=0, b=0, c=0;
float D=0;
cin>>a>>b>>c;
D=b*b-4*a*c;
if (D>0)
cout << "Two different roots x1=" << (-b+sqrt(D))/(2*a) << " , " << "x2=" << (-b-sqrt(D))/(2*a); //第一次作時打成2*a,忘了()
if (D<0 span="">0>
cout << "No real root";
if (D==0)
cout << "Two same roots x=" << (-b+sqrt(D))/(2*a);
return 0;
}
沒有留言:
張貼留言