Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <fstream>
  2. #include <cmath>
  3. using namespace std;
  4. ifstream in("date.in");
  5. ofstream out("date.out");
  6.  
  7.  
  8. struct pct{
  9. char lit;
  10. int x;
  11. int y;
  12. };
  13.  
  14. pct x[8];
  15. int i,j,k;
  16.  
  17. int calc(pct a, pct b){
  18. int f=(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
  19. f=sqrt(f);
  20. return f;
  21. }
  22.  
  23.  
  24.  
  25. int main()
  26. {
  27.  
  28. for(i=1;i<=7;i++){ in>>x[i].lit>>x[i].x>>x[i].y; }
  29.  
  30. for(i=1;i<=7;i++){
  31.  
  32. for(j=i+1;j<=7;j++){
  33.  
  34. for(k=j+1;k<=7;k++){
  35. int c=0, p=0,f=1;
  36.  
  37. int l1=calc(x[i],x[j]);
  38. int l2=calc(x[k],x[j]);
  39. int l3=calc(x[i],x[k]);
  40.  
  41. if(l1==l2) c++;
  42. if(l2==l3) c++;
  43. if(l1==l3) c++;
  44.  
  45. if(l1*l1==l2*l2+l3*l3) p++;
  46. if(l2*l2==l1*l1+l3*l3) p++;
  47. if(l3*l3==l2*l2+l1*l1) p++;
  48.  
  49. out<<x[i].lit<<x[j].lit<<x[k].lit<<" este triunghi ";
  50. if(p&c) out<<"dreptunghic isoscel";
  51. else if(c==1) out<<"isoscel";
  52. else if(c==3) out<<"echilateral";
  53. else if(p) out<<"dreptunghic";
  54. else out<<"oarecare";
  55.  
  56. out<<'\n';
  57.  
  58.  
  59.  
  60.  
  61. }
  62.  
  63. }
  64.  
  65.  
  66. }
  67.  
  68. return 0;
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement