Програма, която намира най-голямото от 10 числа.

23 10 2010

Задача. Да се състави програма, която намира най-голямото от 10 числа.

За решението на програмата е използвана функцията if.

Една програма, която решава задачата е следна:

 #include<iostream>
using namespace std;
int main(){
 cout<<"Programa koqto namira nai-golqmoto ot 10 chisla"<<endl<<endl;
cout<<"A=";int q;cin>>q;
cout<<"B=";int w;cin>>w;
cout<<"C=";int e;cin>>e;
cout<<"D=";int r;cin>>r;
cout<<"E=";int t;cin>>t;
cout<<"F=";int y;cin>>y;
cout<<"G=";int u;cin>>u;
cout<<"I=";int i;cin>>i;
cout<<"J=";int o;cin>>o;
cout<<"K=";int p;cin>>p;

if ((q>w) && (q>e) && (q>r) && (q>t) && (q>y) && (q>u) && (q>i) && (q>o) && (q>p)) cout<<q;

if ((w>q) && (w>e) && (w>r) && (w>t) && (w>y) && (w>u) && (w>i) && (w>o) && (w>p)) cout<<w;

if ((e>q) && (e>r) && (e>w) && (e>t) && (e>y) && (e>u) && (e>i) && (e>o) && (e>p)) cout<<e;

if ((r>q) && (r>p) && (r>w) && (r>e) && (r>t) && (r>y) && (r>u) && (r>i) && (r>o)) cout<<r;

if ((t>q) && (t>r) && (t>w) && (t>e) && (t>y) && (t>u) && (t>i) && (t>o) && (t>p)) cout<<t;

if ((y>q) && (y>r) && (y>w) && (y>e) && (y>t) && (y>u) && (y>i) && (y>o) && (y>p)) cout<<y;

if ((u>q) && (u>r) && (u>w) && (u>e) && (u>t) && (u>y) && (u>i) && (u>o) && (u>p)) cout<<u;

if ((i>q) && (i>r) && (i>w) && (i>e) && (i>t) && (i>y) && (i>u) && (i>o) && (i>p)) cout<<i;

if ((o>q) && (o>r) && (o>w) && (o>e) && (o>t) && (o>y) && (o>u) && (o>i) && (o>p)) cout<<o;

if ((p>q) && (p>r) && (p>w) && (p>e) && (p>t) && (p>y) && (p>u) && (p>i) && (p>o)) cout<<p;

return 0;}

 

~S.K.G~


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: