RafalSobala

zad10

Mar 20th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int a,b,c;
  5.  
  6. int OBWOD_TROJKATA(int a,int b,int c){
  7.  
  8.    if( a + b > c && c + b > a && a + c > b){
  9.  
  10.     return a+b+c;
  11.    }
  12.     else{
  13.         return -1;
  14.     }
  15.  
  16.  
  17. }
  18.  
  19.  
  20. int main()
  21. {
  22.     cout << "1 bok: " << endl;
  23.      cin>>a;
  24.     cout << "2 bok: " << endl;
  25.      cin>>b;
  26.     cout << "3 bok: " << endl;
  27.      cin>>c;
  28.  
  29.      if(OBWOD_TROJKATA(a, b, c) == -1){
  30.       cout << "Nie da się utworzyć trójkąta" << endl;
  31.      }
  32.      else{
  33.     cout << OBWOD_TROJKATA(a, b, c) << endl;
  34.      }
  35.     return 0;
  36.  
  37. }
Add Comment
Please, Sign In to add comment