לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #1  
ישן 24-05-2006, 19:25
  or171 or171 אינו מחובר  
 
חבר מתאריך: 22.04.06
הודעות: 81
באגים בC++

שלום

לא מזמן למדתי C++ וניסיתי להמיר תוכנה שכתבתי בC לC++. יש לי כמה שגיאות קומפילציה שאני לא מצליח לתקן. בבקשה עזרו לי.

קוד:
#include <stdio.h> #include <iostreams.h> #include <math.h> //finish compiling erorrs, restore private class point { public: double x, y; public: point(double x1, double y1): x(x1), y(y1) {} int make_point(double x1, double y1){ x=x1; y=y1; return 0; } int operator==(point a){ if (x==a.x && y==a.y) return 1; else return 0; } } class line { public: double length; point p1, p2; public: int make_line (point a, point b){ p1.make_point(a.x, a.y); p2.make_point(b.x, b.y); length=sqrt( (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y)); return 0; } } class tryangle { public: point p1, p2, p3; line l1, l2, l3; double area, perimeter; public: tryangle(point a, point b, point c) { p1.make_point(a.x, a.y); p2.make_point(b.x, b.y); p3.make_point(c.x, c.y); l1.make_line(p1, p2); l2.make_line(p1, p3); l3.make_line(p2, p3); perimeter=l1.length+l2.length+l3.length; area=sqrt(perimeter/2*(perimeter/2-l1.length)*(perimeter/2-l2.length)*(perimeter/2-l3.length)); } int check(void){ if(p1==p2 || p1==p3 || p2==p3){ printf("Illegal triangle. Some points coincide. Bye...\n"); return 1; } if(fabs( (p3.y-p1.y) * (p2.x-p1.x) - (p2.x-p1.x) * (p3.x-p1.x) ) < 0.001 ) { { printf("Illegal triangle. Three points on one line. Bye...\n"); return 1; } return 0; } } int main(void){ double x1, x2, x3, y1, y2, y3; /*if(scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)!=6){ printf("incorrect data!\n"); return 1; }*/ cin>> x1 >> y1 >> x2 >> y2 >> x3 >> y3; point p1(x1, y1), p2(x2, y2), p3(x3, y3); tryangle t1(p1, p2, p3); if(t1.check()){ return 1; } printf("The edge length: a=%.2lf, b=%.2lf, c=%.2lf\n", t1.l1.length, t1.l2.length, t1.l3.length); printf("The perimeter of the triangle is %.2lf\n", t1.perimeter); printf("The area of the triangle is %.2lf\n", t1.area); return 0; }
_____________________________________

[התמונה הבאה מגיעה מקישור שלא מתחיל ב https ולכן לא הוטמעה בדף כדי לשמור על https תקין: http://www.fresh.co.il/scripts/birthday.php?date=17/01/1991]

תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #2  
ישן 24-05-2006, 20:35
  no nick.inc no nick.inc אינו מחובר  
 
חבר מתאריך: 14.11.04
הודעות: 79
בתגובה להודעה מספר 1 שנכתבה על ידי or171 שמתחילה ב "באגים בC++"

יש לך המון טעויות!!!

תיקנתי את הרוב וסימנתי באדום, את כול השאר תתקן בעצמך!

א.מחלקה צריכה להסגר עם נקודה פסיק.
ב.תמיד תבדוק פתיחה וסגירה של סוגריים (במקרה הזה לא היה לך MAIN בגלל סוגריים מיותרים)

קוד:
#include <stdio.h> //==>#include <iostreams.h> #include <iostream.h> #include <math.h> //finish compiling erorrs, restore private class point { public: double x, y; public: point(double x1, double y1): x(x1), y(y1) {} int make_point(double x1, double y1){ x=x1; y=y1; return 0; } int operator==(point a){ if (x==a.x && y==a.y) return 1; else return 0; } }; class line { public: double length; point p1, p2; public: int make_line (point a, point b){ p1.make_point(a.x, a.y); p2.make_point(b.x, b.y); length=sqrt( (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y)); return 0; } }; class tryangle { public: point p1, p2, p3; line l1, l2, l3; double area, perimeter; public: tryangle(point a, point b, point c) { p1.make_point(a.x, a.y); p2.make_point(b.x, b.y); p3.make_point(c.x, c.y); l1.make_line(p1, p2); l2.make_line(p1, p3); l3.make_line(p2, p3); perimeter=l1.length+l2.length+l3.length; area=sqrt(perimeter/2*(perimeter/2-l1.length)*(perimeter/2-l2.length)*(perimeter/2-l3.length)); } int check(void){ if(p1==p2 || p1==p3 || p2==p3){ printf("Illegal triangle. Some points coincide. Bye...\n"); return 1; } if(fabs( (p3.y-p1.y) * (p2.x-p1.x) - (p2.x-p1.x) * (p3.x-p1.x) ) < 0.001 ) { //{ printf("Illegal triangle. Three points on one line. Bye...\n"); return 1; } return 0; } }; int main(void) { double x1, x2, x3, y1, y2, y3; /*if(scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)!=6){ printf("incorrect data!\n"); return 1; }*/ cin>> x1 >> y1 >> x2 >> y2 >> x3 >> y3; point p1(x1, y1), p2(x2, y2), p3(x3, y3); tryangle t1(p1, p2, p3); if(t1.check()){ return 1; } printf("The edge length: a=%.2lf, b=%.2lf, c=%.2lf\n", t1.l1.length, t1.l2.length, t1.l3.length); printf("The perimeter of the triangle is %.2lf\n", t1.perimeter); printf("The area of the triangle is %.2lf\n", t1.area); return 0; }
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #3  
ישן 24-05-2006, 21:13
  or171 or171 אינו מחובר  
 
חבר מתאריך: 22.04.06
הודעות: 81
בתגובה להודעה מספר 1 שנכתבה על ידי or171 שמתחילה ב "באגים בC++"

תודה רבה וכן יש לי הרבה מאד טעיות, אני בסך הכל מתחיל.

בעיקרון תיקנתי את הטעויות שהראת לי ונשארה רק אחת. משהו על זה שהוא לא מוצא בנאי לp1. הנה הקוד המתוקן.

קוד:
#include <stdio.h> #include <iostreams.h> #include <math.h> //finish compiling erorrs, restore private class point { public: double x, y; public: point(double x1, double y1): x(x1), y(y1) {} int make_point(double x1, double y1){ x=x1; y=y1; return 0; } int operator==(point a){ if (x==a.x && y==a.y) return 1; else return 0; } }; class line { public: double length; point p1, p2; public: int make_line (point a, point b){ p1.make_point(a.x, a.y); p2.make_point(b.x, b.y); length=sqrt( (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y)); return 0; } }; class tryangle { public: point p1, p2, p3; line l1, l2, l3; double area, perimeter; public: tryangle(point a, point b, point c){ p1.make_point(a.x, a.y); p2.make_point(b.x, b.y); p3.make_point(c.x, c.y); l1.make_line(p1, p2); l2.make_line(p1, p3); l3.make_line(p2, p3); perimeter=l1.length+l2.length+l3.length; area=sqrt(perimeter/2*(perimeter/2-l1.length)*(perimeter/2-l2.length)*(perimeter/2-l3.length));} int check(void){ if(p1==p2 || p1==p3 || p2==p3){ printf("Illegal triangle. Some points coincide. Bye...\n"); return 1;} if(fabs( (p3.y-p1.y) * (p2.x-p1.x) - (p2.x-p1.x) * (p3.x-p1.x) ) < 0.001 ) { { printf("Illegal triangle. Three points on one line. Bye...\n"); return 1;} return 0; }} }; int main(void){ double x1, x2, x3, y1, y2, y3; /*if(scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)!=6){ printf("incorrect data!\n"); return 1; }*/ cin>> x1 >> y1 >> x2 >> y2 >> x3 >> y3; point p1(x1, y1), p2(x2, y2), p3(x3, y3); tryangle t1(p1, p2, p3); if(t1.check()){ return 1; } printf("The edge length: a=%.2lf, b=%.2lf, c=%.2lf\n", t1.l1.length, t1.l2.length, t1.l3.length); printf("The perimeter of the triangle is %.2lf\n", t1.perimeter); printf("The area of the triangle is %.2lf\n", t1.area); return 0; }
_____________________________________

[התמונה הבאה מגיעה מקישור שלא מתחיל ב https ולכן לא הוטמעה בדף כדי לשמור על https תקין: http://www.fresh.co.il/scripts/birthday.php?date=17/01/1991]

תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 21:49

הדף נוצר ב 0.05 שניות עם 10 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר