Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int a,b,c;
- cout << "Enter triangle's sides\n";
- int ar[3];
- for (int i = 0; i < 3; ++i)
- cin >> ar[i];
- if (ar[0] <= 0 || ar[1] <= 0 || ar[1] <= 0){
- cout << "trinagle does not exist";
- return 0;
- }
- a = min(min(ar[0],ar[1]),ar[2]);
- c = max(max(ar[0],ar[1]),ar[2]);
- b = ar[0]+ar[1]+ar[2] - a - c;
- if (cin.fail()) {cout << "enter data again"; return 0;}
- if (a + b < c) {
- cout << "triangle does not exist";
- return 0;
- }
- if (a*a + b*b == c*c)
- cout << "right triangle";
- else
- cout << "not right triangle";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement