Answer the question
In order to leave comments, you need to log in
Where is the logical fallacy?
Task: find the area of an isosceles trapezoid with bases a and b and angle alpha with a larger base a.
int a,b;
cout << "Input length of the lower base: ";
cin >> a;
cout << "Input length of the upper base: ";
cin >> b;
float angle;
cout << "Input angle: ";
cin >> angle;
angle = (angle*pi)/180.;//перевод градусов у радианы
float c = (a-b)/2*cos(angle);//сторона трапеции
//здесь делал точку останова - данные правильно вычисляются
float s = ((a+b)/2.)*sqrt((float)pow(c,2) - ((float)pow(a-b,2))/4.);//вычисление площади http://www-formula.ru/index.php/2011-09-19-02-39-24/trapeze-area
printf("Area: %.3f\n\n",s);
Answer the question
In order to leave comments, you need to log in
Too hard to calculate. It is better to first analytically simplify the formula, then there will be less room for errors in the program.
Let the lower (greater) base a , upper (smaller) - b .
The height of the trapezoid (isosceles) h = (ab)*tg(α)/2
The area of the trapezoid S = (a+b)*h/2 = (a+b)*(ab)*tg(α)/4 = (a 2 -b 2 )*tg(α)/4
You get a negative number under the root, due to the fact that the lateral side was incorrectly calculated. See right triangle formulas. To make it easier - do not write the whole formula, break it down into its component parts. And debug will be simple.
Trapezium area: S \u003d (a + b) * h / 2. Where do you get the power functions and the square root I can not understand.
h can be calculated in terms of solving the triangle. where h is one leg, the second: (ba) / 2 since you have an isosceles trapezoid, and the tangent / cotangent of the angle you have.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question