안녕하세요 숙제를위한 솔루션 코드를 작성하는 데 문제가 있습니다. 나는 사용자에게 2 개의 방정식을위한 6 개의 변수를 입력하라고 요구할 필요가있다. 성공적으로 숫자를 가져온 후에는 각 행의 기울기, 각 행의 y 절편, 솔루션이있는 경우 각 행의 두 점 ((2,1)과 같은 순서쌍)을 찾아야합니다. 또한 관계가 무엇인지. 나는 주로 숫자 검사와 방정식을 수색하고 수색했다. 제가 문제가되는 것은 방정식에 대한 요점과 해답을 찾는 것입니다.C++을 사용하는 2 선형 방정식 시스템
#include <iostream>
#include <limits>
int main()
{
std::cout<<"This program is designed to test two linear equations. \n";
std::cout<<"In order to best solve the system, \n";
std::cout<<"equations will be in the form of a*x + b*y = c. \n";
std::cout<<"and d*x + e*y =f. \n";
std::cout<<"Please enter an integer for a, b, and c. \n";
double a, b, c, d, e, f;
while ((std::cout << "Enter a.")
&& !(std::cin >> a))
{
std::cout << "That's not a number ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
while ((std::cout << "Enter b.")
&& !(std::cin >> b))
{
std::cout << "That's not a number ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
while ((std::cout << "Enter c.")
&& !(std::cin >> c))
{
std::cout << "That's not a number ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
std::cout<<"Equation 1 is "<<a<<"x +"<<b<<"y ="<<c;
std::cout<<"Please enter an integer for d, e, and f. \n";
while ((std::cout << "Enter d.")
&& !(std::cin >> d))
{
std::cout << "That's not a number ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
while ((std::cout << "Enter e.")
&& !(std::cin >> e))
{
std::cout << "That's not a number ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
while ((std::cout << "Enter f.")
&& !(std::cin >> f))
{
std::cout << "That's not a number ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
std::cout<<"Equation 2 is "<<d<<"x +"<<e<<"y ="<<f;
double slope1, slope2;
double x1, x2, y1, y2;
slope1 = (b/a);
slope2 = (e/d);
std::cout<<" Slope of Equation 1 is "<<slope1<<"\n";
std::cout<<" Slope of Equation 2 is "<<slope2<<"\n";
x1 = ((c*e)-(b*f))/ ((a*e)-(b*d));
y1 = ((a*f)-(c*d))/ ((a*e)-(b*d));
return 0;
}
구체적인 질문이 무엇인지 명확히 할 수 있습니까? –
나의 구체적인 질문은 어떻게 각 방정식의 선상에 2 점을 얻고 방정식을 풀 수 있는가이다. –