The lengths of the sides of the triangle are entered from the keyboard. It is necessary to output "exists" if such a triangle can exist, if it cannot output "does not exist". Solve through case of.
Closed due to the fact that the essence of the issue is not clear to the participants of Regent , aleksandr barakin , Denis , cheops , ermak0ff 14 Feb '17 at 5:59 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
- 3What exactly you can not? - Mae
- oneSo is C # or Pascal? - VladD
- Better Pascal :) - Pipok
- onecase of (a + b> c) and (b + c> a) and (c + a> b) true: WriteLn ("Exists"); false: WriteLn ("Does not exists"); end; - Igor
- one@Pipok - Is this really what was meant in the task? I wrote it with a fair amount of sarcasm. - Igor
1 answer
The verification is actually very simple: a triangle with sides a , b and c exists if and only if the lengths are positive and the triangle inequality holds:
a > 0 && b > 0 && c > 0 && a + b > c && b + c > a && c + a > b Entering numbers from the console into variables and outputting the result, I think, you will organize yourself.
Update: as @Igor correctly states in the commentary, non-negativity checks are not needed, since they follow from the triangle inequality. Indeed, if a + b > c and c + a > b , adding, we get 2a + b + c > b + c , that is, 2a > 0 . So, just check it out
a + b > c && b + c > a && c + a > b - Thank you, but it is necessary through the case of) - Pipok
- 2
a > 0 && b > 0 && c > 0- not needed - Igor - @Igor: Right, thanks! Updated the answer. - VladD
- one@Pipok and what, case of a boolean type does not work anymore? .. - Pavel Mayorov