Advertisement
rengetsu

ProcedurProgramavimas_3.05

Apr 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <conio.h>
  5. #include <math.h>
  6. using namespace std;
  7. double x[4], y[4], max=-1000000, perimetras, plotas, d1, d2, d3, d4;
  8.  
  9. void Staciakampis()
  10. {
  11.     d1=sqrt(pow(x[1]-x[0],2)+pow(y[1]-y[0],2));
  12.     d2=sqrt(pow(x[2]-x[1],2)+pow(y[2]-y[1],2));
  13.     d3=sqrt(pow(x[3]-x[2],2)+pow(y[3]-y[2],2));
  14.     d4=sqrt(pow(x[0]-x[3],2)+pow(y[0]-y[3],2));
  15.     perimetras = d1+d2+d3+d4;
  16.     plotas = d1*d2;
  17.     cout<<fixed<<setprecision(5)<<plotas<<endl;
  18.     cout<<fixed<<setprecision(5)<<perimetras<<endl;
  19. }
  20.  
  21. int main()
  22. {
  23.     for(int i=0;i<4;i++)
  24.     {
  25.         cin>>x[i];
  26.         cin>>y[i];
  27.         if(x[i] > max)
  28.         {
  29.             max = x[i];
  30.         }
  31.         if(y[i] > max)
  32.         {
  33.             max = y[i];
  34.         }
  35.     }
  36.     Staciakampis();
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement