Can you explain why I can not see the abs definition, because when I execute it I get a message saying
error: 'abs' not declared in this scope
note: I use the codeblocks compiler 13.12
#include<iostream>
#include<math.h>
using namespace std;
int main(){
float a,b,c,d,e = 0,f,x,y;
cout<<"numero de vertices : ";
cin>>f;
cin>>a>>b;
x = a;
y = b;
for(int i = 0; i < f; i++){
cin>>c>>d;
x = x - c;
y = y - d;
x = abs(x);
y = abs(y);
e = e + sqrt(x*x + y*y);
x = c; // un arreglo en el codigo
y = d; // un arreglo en el codigo
}
x = x - a;
y = y - b;
x = abs(x);
y = abs(y);
e = e + sqrt(x*x+ y*y);
cout<<e;
}
note: the code is to solve this exercise.
- Polygon--
Make a program that reads a sequence of 2D points (real pairs) that represent a polygon (the last point of the sequence is the same as the first), and determines the length of its perimeter.
font link