الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

تصحيح كود c++

بدأه سرمد الليل في 22 أبريل 2010 · 3 رد · 1,207 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السوال:

Write a program that asks the user to enter the lengths of three sides of a triangle, then displays a message to indicate whether the triangle is a right triangle or not.

Hints:

-The triangle is right triangle when the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides.

-Lengths of the triangle should be positive numbers.

محاولتى :

#include <iostream>

using namespace std;

int main()

{

int a,c,d;

cout<<"enter the lengths three side";

cin>>a,b,c;

if(a*a==((b+c)*(b+c)))

cout<<"triangle is a right ";

else

cout<<"not"

return 0 ;

}

#2

قمت بتصحيح الكود :) مع أنني لا أعرف الإنجليزية :blush: و لكنني قمت بترجمة المطلوب في google و وجدت مفهوم تقريبي لمقصد التمرين :wacko:

ولكن في المرات القادمة عليك بكتابة نص التمرين باللغة العربية :wink: لكي يكون سهل القراءة من طرف الجميع :)

الكود بعد التعديل:

#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cout<<"enter the lengths three side";
    cin>>a>>b>>c;
    if(a*a==(b*b)+(c*c))
     cout<<"triangle is a right "<<endl;
    else
     cout<<"not"<<endl;
    system("pause");
    return 0 ;
}

تحياتي.

#3

السلام عليكم.

هذا الكود ربما اكثر دقة :

#include <iostream>

using namespace std;


int main(int argc, char *argv[])
{
 	int a,b,c; 
 	cout<<" enter the lengths three side:";
 	cin>>a>>b>>c;    	
 	if((a*a==b*b+c*c)||(b*b==a*a+c*c)||(c*c==a*a+b*b))
 	cout<<"triangle is a right ";
 	else cout<<"triangle is not a right ";
   return 0;
}
tvquran_6.gif

#4

الله يجزاكم خير

مواضيع مشابهة