G
G
grecigor2020-12-17 02:44:07
C++ / C#
grecigor, 2020-12-17 02:44:07

Sieve how to sort correctly?

Decision for school, I need to get 5, but programming is difficult.

You can use any language, I'll figure it out later (probably)

Condition - Iron balls of 4 sizes are sorted by diameter using three sieves, which are placed one above the other. Each sieve has only one diameter, which corresponds to one of the three ball diameters, excluding the largest ball. Behind the known diameters of the sieves, arrange them in an order that would ensure sorting.

Here's what I've done so far, I don't know how.

#include <iostream>
#include <cmath>

using namespace std;
int main(){

    int p;
    int a,b,c,d;
    int s1,s2,s3;

    cin>>a>>b>>c>>d;
    cout<<"Vvedite sito"<<endl;
    cin>>s1>>s2>>s3;

    if(a<b){
      p=a;
      a=b;
      b=p;



    }if(b<c){
        p=b;
        b=c;
        c=p;

    }if(c<d){
        p=c;
        c=d;
        d=p;

    }

    cout<<a<<b<<c<<d<<endl;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Homemade, 2020-12-17
@Homemade

Just print the sieve diameters in descending order.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question