كان أحد الأخوة نزلنا كتابC++ هنا في موضوع .. المهم في الواجب بتاع if
اقتباس:
س 1 اكتب برنامج طٌلب من المستخدم إدخال درجته ثم قٌوم البرنامج بطباعة (a,b,c,d,f ) وذالك حسب الدرجة المعطاة
|
ده تطبيقي
كود:
#include <iostream>
using namespace std;
int main()
{
float a,b,c,d,f ;
cout<<"Enter your degrees :"<<endl;
cin>>a>>b>>c>>d>>f;
if((a>b&&a>c&&a>d&&a>f)&&(b>c&&b>d&&b>f)&&(c>d&&c>f)&&(d>f)){
cout<<"the sequence of the degrees is :\n"<<a<<"\n"<<b<<"\n"<<c<<"\n"<<d<<"\n"<<f<<endl;
cin.get();
}
else if ((b>a&&b>c&&b>d&&b>f)&&(a>c&&a>d&&a>f)&&(c>d&&c>f)&&(d>f)){
cout<<"the sequence of the degrees is :\n"<<b<<"\n"<<a<<"\n"<<c<<"\n"<<d<<"\n"<<f<<endl;
cin.get();
}
else if ((c>a&&c>b&&c>d&&c>f)&&(a>b&&a>d&&a>f)&&(b>d&&b>f)&&(d>f)){
cout<<"the sequence of the degrees is :\n"<<c<<"\n"<<a<<"\n"<<b<<"\n"<<d<<"\n"<<f<<endl;
cin.get();
}
else if ((d>a&&d>b&&d>c&&d>f)&&(a>b&&d>a&&a>f)&&(b>c&&b>f)&&(c>f)){
cout<<"the sequence of the degrees is :\n"<<d<<"\n"<<a<<"\n"<<b<<"\n"<<c<<"\n"<<f<<endl;
cin.get();
}
else if ((f>a&&f>b&&f>d&&f>c)&&(a>b&&a>d&&a>c)&&(b>d&&b>c)&&(c>d)){
cout<<"the sequence of the degrees is :\n"<<f<<"\n"<<a<<"\n"<<b<<"\n"<<c<<"\n"<<d<<endl;
cin.get();
}
return 0;
}
هنا مبتشتغلش إلا في الحالة الأولى بس.. حاجة كمان لو فيه درجات متساوية تتعمل إزاي ؟