Pagini recente » Cod sursa (job #2348409) | Cod sursa (job #283739) | Cod sursa (job #833978) | Cod sursa (job #1928320) | Cod sursa (job #3351648)
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
struct Point {
int x, y;
};
const int INF = INT_MAX;
double eps;
double dist(Point P1, Point P2) {
return ( sqrt( ( (P2.x - P1.x) * (P2.x - P1.x) ) + ( (P2.y - P1.y) * (P2.y - P1.y) ) ) );
}
bool SamePoint(Point P1, Point P2) {
if ( ( fabs(P1.x - P2.x) < eps ) && ( fabs(P1.y - P2.y) < eps ) ) {
return 1;
}
return 0;
}
Point median(Point P1, Point P2) {
Point M;
M.x = (P1.x + P2.x) / 2;
M.y = (P1.y + P2.y) / 2;
return M;
}
double slope(Point P1, Point P2) {
if (fabs(P2.x - P1.x) < eps)
return INF;
else
return ((P2.y - P1.y) / (P2.x - P1.x));
}
ifstream I("trapez.in");
ofstream O("trapez.out");
const int GMAN = 10005;
double pante[GMAN];
Point toyota[GMAN];
int main(){
int n, Ebony = 0, Ivory = 0, c = 0, r = 0;
I >> n;
for (int i = 0; i < n; i++) {
I >> toyota[i].x >> toyota[i].y;
}
while (true) {
if (Ivory = n) {
Ebony++;
Ivory = Ebony + 1;
if (Ebony >= n) break;
}
else {
Ivory++;
}
pante[c] = slope(toyota[Ebony], toyota[Ivory]);
c++;
}
//sort(pante[0], pante[c]);
for (int i = 0; i < c; i++) {
if (!pante[i]) r++;
}
O << r;
return 0;
}