السلام عليكم ورحمة الله وبركاتة
هذة إجابتى على هذا السؤال
(برنامج يستقبل 5 أرقام صحيحة ويقوم بطباعة أكبر رقم وأصغر رقم)
ولكن أظن ان هناك طريقة أسرع للحل فهل من طريقة أخرى وجزاكم الله خيرا
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d,e;
cout<<"please Enter frist number =";cin>>a;cout<<"please Enter sconde number =";cin>>b;cout<<"please Enter third number =";cin>>c;cout<<"please Enter forth number =";cin>>d;cout<<"please Enter five number =";cin>>e;
if(a>b && a>c && a>d && a>e)
cout <<"the biggest number was "<<a<<endl;
else if(b>a && b>c && b>d && b>e)
cout <<"the biggest number was "<<b<<endl;
else if(c>a && c>b && c>d && c>e)
cout <<"the biggest number was "<<c<<endl;
else if(d>a && d>b && d>c && d>e)
cout <<"the biggest number was "<<d<<endl;
else if(e>a && e>b && e>c && e>d)
cout <<"the biggest number was "<<e<<endl;
/*--------------------------*/
if(a<b && a<c && a<d && a<e)
cout <<"the smallest number was "<<a<<endl;
else if(b<a && b<c && b<d && b<e)
cout <<"the smallest number was "<<b<<endl;
else if(c<a && c<b && c<d && c<e)
cout <<"the smallest number was "<<c<<endl;
else if(d<a && d<b && d<c && d<e)
cout <<"the smallest number was "<<d<<endl;
else if(e<a && e<b && e<c && e<d)
cout <<"the smallest number was "<<e<<endl;
system("pause");
return 0;
}
