Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Triagolnici

By: velimir on Mar 30th, 2013  |  syntax: C++  |  size: 0.78 KB  |  views: 66  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. struct pole{
  7.     int x, y;
  8. };
  9. int main()
  10. {
  11.     int n, i, j, l, count=0, a, b, c;
  12.     cin >> n;
  13.     pole niza[n];
  14.     for(i = 0; i<n; i++)cin >> niza[i].x >> niza[i].y;
  15.     for(i = 0; i<n; i++)
  16.         for(j = i+1; j<n; j++)
  17.             for(l = j+1; l<n; l++)
  18.             {
  19.                 a = (pow(niza[j].x-niza[l].x, 2) + pow(niza[j].y-niza[l].y, 2))+0.00001;
  20.                 b = (pow(niza[i].x-niza[l].x, 2) + pow(niza[i].y-niza[l].y, 2))+0.00001;
  21.                 c = (pow(niza[i].x-niza[j].x, 2) + pow(niza[i].y-niza[j].y, 2))+0.00001;
  22.                 if(c == a+b)count++;
  23.                 else if(a == c+b)count++;
  24.                 else if(b == a+c)count++;
  25.             }
  26.     cout << count;
  27.     return 0;
  28. }
clone this paste RAW Paste Data