Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- /*8.Napisz program pobierający od użytkownika 3 liczby
- i drukujący na ekranie te liczby w kolejności niemalejącej. */
- int x,y,z;
- cout<<"Podaj 3 liczby"<<endl;
- cout<<"Podaj liczbe x:"<<endl;
- cin>>x;
- cout<<"Podaj liczbe y:"<<endl;
- cin>>y;
- cout<<"Podaj liczbe z:"<<endl;
- cin>>z;
- if(x<y&&x<z) // x jest najmniejsze
- {
- if(y<z)
- {
- cout<<x<<" "<<y<<" "<<z;
- }
- else
- {
- cout<<x<<" "<<z<<" "<<y;
- }
- }
- else if (y<x&&y<z) // y jest najmniejsze
- {
- if(x<z)
- {
- cout<<y<<" "<<x<<" "<<z;
- }
- else
- {
- cout<<y<<" "<<z<<" "<<x;
- }
- }
- else // z jest najmniejsze
- {
- if(x<y)
- {
- cout<<z<<" "<<x<<" "<<y;
- }
- else
- {
- cout<<z<<" "<<y<<" "<<x;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement