|
|
вернуться в форумplease help, what's wrong on this? #include <iostream> #include <math.h> #include <iomanip> using namespace std; void main() { double x[99],y[99],r,n,dlina[99]; cin >> n >> r; double P=2*3.14*r; for (int i=0; i<=n-1; i++) { cin >> x[i] >> y[i]; } for (int j=0; j<=n-1; j++) { if (j!=(n-1)) { dlina[j]=sqrt((x[j]-x[j+1])*(x[j]-x[j+1])+(y[j]-y[j+1])*(y[j]-y[j+1])); P+=dlina[j]; } else { dlina[j]=sqrt((x[j]-x[0])*(x[j]-x[0])+(y[j]-y[0])*(y[j]-y[0])); P+=dlina[j]; } } cout << setprecision(2) << setiosflags (ios::showpoint | ios::fixed) << P;
} |
|
|