פורסם 2007 בדצמבר 2117 שנים #include<iostream.h>#include<math.h>class point{ int x,y;friend class polygon;public: point() { x=0; y=0; } void set(int a, int b) { if(a<0) a=0; else x=a; if(b<0) b=0; else y=b; } point(int a, int b) { set(a,b); } double distance(point p) { return sqrt(abs((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))); } void print(double res) { cout<<"x:"<<x<<endl; cout<<"y:"<<y<<endl; cout<<"distance: "<<res<<endl; }};class polygon{ point *ptr; int size;public: polygon() { ptr=NULL; size=0; } void set(int s) { int a,b; ptr = new point[s]; cout<<"enter nums..."<<endl; for(int i=0;i<s;i++) { cin>>a>>b; ptr[i].set(a,b); } size = s; } polygon(int size) { set(size); } polygon(polygon &other) { size=other.size; ptr = new point[size]; for(int i=0;i<size;i++) { ptr[i] = other.ptr[i]; } } void operator=(polygon &other) { if(other.ptr=NULL) { ptr = NULL; size = 0; } else { size=other.size; ptr = new point[size]; for(int i=0;i<size;i++) ptr[i] = other.ptr[i]; } } double hekef(point p) { double sum=0; point tmp; sum = tmp.distance(p); return sum; } void print() { int i; for(i=0;i<size;++i) { cout<<endl; cout<<"x"<<i+1<<": "<<ptr[i].x<<endl; cout<<"y"<<i+1<<": "<<ptr[i].y<<endl; } } ~polygon() { delete []ptr; }};int main(){ int s,n1,n2; double sum=0; point x(5,10),y(7,8),poly; polygon a(2),b; cin>>s; for (int i=1;i<=s;i++) { cin>>n1>>n2; poly.set(n1,n2); sum+=b.hekef(poly); } x.print(x.distance(y)); a.print(); return 0;}אני משתמש כעיקרון בויז'ואל אבל הייתי חיחיב חהשתמש ב dev ויש כמה בעיות שאני לא ממש מביןוהנה הבעיות: 1 D:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from D:\Dev-Cpp\îçùáéí\exe test.cpp In file included from D:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from D:\Dev-Cpp\îçùáéí\exe test.cpp 1 D:\Dev-Cpp\îçùáéí\exe test.cpp from D:\Dev-Cpp\îçùáéí\exe test.cpp 32:2 D:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. אני ממש יודה אם מישו יוכל לעזור לי...
פורסם 2007 בדצמבר 2117 שנים אלה רק אזהרות, לא שגיאות.iostream.h ו-math.h הם הדרים מיושנים, ויש קומפיילרים שלא אוהבים את זה. במקומם אתה צריך להשתמש ב-iostream וב-cmath (שניהם בלי סיומת h.) ואחרי שורת האינקלוד צריך להוסיף את השורהusing namespace std;
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.